使用 Wordly API 构建。
使用服务器端 API 密钥,发出 HTTPS 请求,并通过可预测的基于信用的计费模型跟踪每个呼叫。该参考记录了当前生产中可用的端点,并明确标记了仍在准备中的端点。
快速入门
创建一个免费帐户,使用六位数代码验证您的电子邮件,然后复制开发人员仪表板中显示的 API 密钥。
- 1创建帐户
仅使用电子邮件地址和密码进行注册。
- 2验证您的电子邮件
输入发送者发送的代码
[email protected]. Verification grants 50 free credits. - 3存储您的 API 密钥
复制生成的
wly_live_...key 并将其保存在服务器端环境变量中。 - 4提出测试请求
调用账户端点验证身份验证并查看剩余余额。
curl "https://api.wordlyenglish.com/v1/account" \
-H "Authorization: Bearer $WORDLY_API_KEY" \
-H "Accept: application/json"{
"data": {
"message": "Authenticated",
"credits_remaining": 50
},
"meta": { "lang": "en" }
}基本 URL 和版本控制
所有生产端点均通过以下版本化基本 URL 提供服务:
https://api.wordlyenglish.com/v1破坏响应或行为更改将使用新的路径版本。可以在其中引入附加字段 v1, so clients should ignore response properties they do not recognize.
认证
经过身份验证的端点需要 HTTP 中的 API 密钥 Authorization 使用承载方案的标头。
Authorization: Bearer wly_live_your_api_key切勿将实时密钥放置在浏览器 JavaScript、公共 Git 存储库、屏幕截图、日志或分布式移动应用程序中。从您的后端调用 Wordly API,并让您自己的应用程序与该后端进行通信。
本地化 API 消息
设置响应语言 ?lang=tr 或标准 Accept-Language 标头。查询参数优先。每个 JSON 响应都声明所选区域设置 Content-Language 和 meta.lang. Error codes remain stable in English for programmatic handling; only the human-readable message is localized.
curl "https://api.wordlyenglish.com/v1/account?lang=tr" \
-H "Authorization: Bearer $WORDLY_API_KEY" \
-H "Accept-Language: tr-TR"支持的语言代码: en, tr, de, fr, es, it, pt, nl, pl, ru, uk, ar, fa, he, hi, bn, ur, zh, ja, ko, id, ms, vi, th, sv, no, da, fi, cs, ro.
积分和计费
Each successful metered request consumes the documented number of credits. Email-verified accounts receive 50 free credits once. Credits are deducted atomically, so concurrent requests cannot spend the same balance twice. Balance lookup through GET /v1/account is free.
| 操作 | 信贷成本 | 可用性 |
|---|---|---|
GET /v1/status | 0 | 直播 |
GET /v1/account | 0 | 直播 |
GET /v1/words/{word} | 1–5 | 直播 |
GET /v1/words/search | 1 | 直播 |
GET /v1/words/random | 1 per word | 直播 |
POST /v1/words/batch | 根据返回的记录 | 直播 |
Use GET /v1/account when you need the current balance. Other endpoint responses include the operation charge but omit the remaining balance. When the balance is insufficient, the API returns HTTP 402 并且不处理该操作。
{
"error": {
"code": "credits_exhausted",
"message": "Your credit balance is exhausted. Add a package or enable pay-as-you-go to continue.",
"upgrade_url": "/app.php?page=billing"
}
}API key lifecycle
为开发、暂存和生产创建单独的密钥。 Wordly 仅存储每个密钥的加密哈希值;完整值在创建时显示一次。
- 按环境或服务命名键。
- 使用环境变量或托管秘密存储。
- 如果密钥可能已泄露,请立即撤销该密钥。
- 轮换密钥而不重复使用旧值。
- 不要在查询字符串中发送键。
响应格式
成功的响应使用顶级 data 对象,并且可能包括一个 meta 对象。错误总是使用顶级 error 具有稳定的机器可读对象 code 和人类可读的 message.
{
"data": { ... },
"meta": {
"credits_used": 1,
"request_id": "..."
}
}{
"error": {
"code": "invalid_api_key",
"message": "..."
}
}保留 request_id 当联系支持人员了解成功的计费请求时。 JSON 采用 UTF-8 编码,客户端应发送 Accept: application/json.
Wordly caches shared vocabulary data on the server, never API keys, account identities, balances, rate-limit state, or request identifiers. Public status and language responses advertise shared-cache lifetimes. Authenticated responses remain private, no-store; applications may cache the stable data value in their own trusted backend when appropriate.
生产端点
/v1/status直播返回公共服务运行状况和API版本信息。此端点不需要身份验证并且成本为零。
请求示例
curl "https://api.wordlyenglish.com/v1/status" \
-H "Accept: application/json"200 · Success
{
"data": { "status": "ok", "version": "v1" },
"meta": { "lang": "en" }
}/v1/accountLive · 0 creditsValidates the supplied key and returns the current account balance without charging a credit.
标头
| 名称 | 必填 | 描述 |
|---|---|---|
Authorization | 是的 | Bearer wly_live_... |
Accept | 推荐 | application/json |
响应标头
X-Credits-Remaining is returned only by this balance endpoint.
200 · Success
{
"data": { "message": "Authenticated", "credits_remaining": 1250 },
"meta": { "lang": "en" }
}词汇端点
每条记录都报告其 completeness 作为 catalog, translated, or enriched. Fields that are not available are returned as null 或一个空对象而不是发明的数据。
GET /v1/words/{word}
返回精确的单词匹配。使用 languages=tr,de,fr 仅返回请求的翻译。目录或翻译记录花费 1 个学分;完全丰富的配置文件需要 5 个学分。
curl "https://api.wordlyenglish.com/v1/words/water?languages=tr,de" \
-H "Authorization: Bearer $WORDLY_API_KEY"GET /v1/words/search
搜索方式 q 和可选的 level, part_of_speech, category, limit, and cursor. Limits range from 1 to 50. Pass meta.next_cursor 进入下一个请求。
curl "https://api.wordlyenglish.com/v1/words/search?q=app&level=advanced&limit=20" \
-H "Authorization: Bearer $WORDLY_API_KEY"GET /v1/words/random
返回 1–20 个随机单词。过滤依据 level, part_of_speech, or category. Each returned slot costs one credit.
POST /v1/words/batch
在单个请求中查找 1 到 50 个唯一单词。响应保留请求顺序并标记每个项目 found.
curl -X POST "https://api.wordlyenglish.com/v1/words/batch?lang=tr" \
-H "Authorization: Bearer $WORDLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"words":["water","opportunity"],"languages":["tr","de"]}'GET /v1/languages
返回所有 30 个受支持的接口和 API 消息区域设置。仅在可用时返回词汇翻译。该端点是公共的并且成本为零。
速率限制
每个 API 密钥每滚动分钟最多只能接受 120 个请求。回应包括 X-RateLimit-Limit 和 X-RateLimit-Remaining. A 429 rate_limit_exceeded 回应包括 Retry-After: 60.
/v1/languagesLive · 0 creditsLists all supported interface and API-message locales. Vocabulary translations are returned only when a record contains them.
Query parameters
| 名称 | Type | 必填 | Rules | 描述 |
|---|---|---|---|---|
lang | string | No | Supported locale code | Language for human-readable messages. |
请求示例
curl "https://api.wordlyenglish.com/v1/languages?lang=tr"200 · Success
{
"data": [{
"code": "tr",
"name": "Türkçe",
"message_localization": true,
"vocabulary_translation": "when_available"
}],
"meta": { "count": 30, "lang": "tr" }
}/v1/words/{word}Live · 1–5 creditsReturns one exact vocabulary record. Catalog and translated records cost 1 credit; enriched records cost 5 credits.
Parameters
| 名称 | Location | Type | 必填 | Rules and meaning |
|---|---|---|---|---|
word | Path | string | 是的 | Exact word or slug; maximum 120 characters. URL-encode special characters. |
languages | Query | string | No | Comma-separated translation codes, for example tr,de,fr. |
lang | Query | string | No | Human-readable message language; not a vocabulary filter. |
请求示例
curl "https://api.wordlyenglish.com/v1/words/water?languages=tr,de" \
-H "Authorization: Bearer $WORDLY_API_KEY" \
-H "Accept: application/json"200 · Success
{
"data": {
"id": "water",
"word": "water",
"part_of_speech": "noun",
"level": "basic",
"definition": "A clear liquid essential for life.",
"example": "Please drink enough water every day.",
"translations": { "tr": "su", "de": "Wasser" },
"categories": ["nature", "daily-life"],
"media": {
"image_url": "https://media.example/water.webp",
"audio_url": "https://media.example/water.mp3",
"attribution": {}
},
"completeness": "enriched"
},
"meta": {
"credits_used": 5,
"request_id": "5ebac760-cdc5-4a73-a87b-22463d81483c",
"lang": "en"
}
}404 · Word unavailable
{
"error": { "code": "word_not_found", "message": "The requested word was not found." },
"meta": { "lang": "en" }
}/v1/words/search直播 · 1 学分Searches active vocabulary in alphabetical order. Use the returned cursor for stable forward pagination.
Query parameters
| 名称 | Type | 必填 | Default / limit | 描述 |
|---|---|---|---|---|
q | string | No | Max 120 chars | Case-insensitive contained text. |
level | string | No | Max 30 chars | Exact level filter. |
part_of_speech / pos | string | No | Max 40 chars | Exact grammatical-class filter. |
category | string | No | Max 80 chars | Category-array filter. |
limit | integer | No | 20; min 1, max 50 | Maximum returned records. |
cursor | string | No | Max 120 chars | Previous meta.next_cursor. |
languages | string | No | Comma-separated | Translations to include. |
请求示例
curl "https://api.wordlyenglish.com/v1/words/search?q=app&level=advanced&languages=tr&limit=2" \
-H "Authorization: Bearer $WORDLY_API_KEY"200 · Success
{
"data": [{
"id": "application",
"word": "application",
"part_of_speech": "noun",
"level": "advanced",
"definition": null,
"example": null,
"translations": { "tr": "uygulama" },
"categories": [],
"media": { "image_url": null, "audio_url": null, "attribution": {} },
"completeness": "translated"
}],
"meta": { "credits_used": 1, "request_id": "...", "lang": "en", "count": 1, "next_cursor": null }
}/v1/words/randomLive · 1 credit per requested slotReturns random active words for quizzes, discovery feeds, and practice sessions.
Query parameters
| 名称 | Type | 必填 | Default / limit | 描述 |
|---|---|---|---|---|
count | integer | No | 1; min 1, max 20 | Requested slots and credit cost. |
level | string | No | Exact value | Level filter. |
part_of_speech / pos | string | No | Exact value | Grammatical-class filter. |
category | string | No | Exact value | Category filter. |
languages | string | No | Comma-separated | Translations to include. |
请求示例
curl "https://api.wordlyenglish.com/v1/words/random?count=3&level=basic&languages=tr" \
-H "Authorization: Bearer $WORDLY_API_KEY"200 · Success
{
"data": [{ "id": "water", "word": "water", "part_of_speech": "noun", "level": "basic", "definition": null, "example": null, "translations": { "tr": "su" }, "categories": [], "media": { "image_url": null, "audio_url": null, "attribution": {} }, "completeness": "translated" }],
"meta": { "credits_used": 3, "request_id": "...", "lang": "en", "count": 1 }
}/v1/words/batchLive · calculatedLooks up 1–50 unique words while preserving request order. Each enriched result costs 5 credits, another found result costs 1, and the minimum request charge is 1.
标头
| 名称 | 必填 | Value |
|---|---|---|
Authorization | 是的 | Bearer wly_live_... |
Content-Type | 是的 | application/json |
Accept | 推荐 | application/json |
JSON body
| Field | Type | 必填 | Rules | 描述 |
|---|---|---|---|---|
words | string[] | 是的 | 1–50 items; each max 120 chars | Words to resolve; duplicates are normalized and removed. |
languages | string[] | No | Supported locale codes | Translations to include. |
请求示例
curl -X POST "https://api.wordlyenglish.com/v1/words/batch?lang=tr" \
-H "Authorization: Bearer $WORDLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"words":["water","not-a-word"],"languages":["tr","de"]}'200 · Success
{
"data": [
{ "query": "water", "found": true, "word": { "id": "water", "word": "water", "part_of_speech": "noun", "level": "basic", "definition": null, "example": null, "translations": { "tr": "su", "de": "Wasser" }, "categories": [], "media": { "image_url": null, "audio_url": null, "attribution": {} }, "completeness": "translated" } },
{ "query": "not-a-word", "found": false, "word": null }
],
"meta": { "credits_used": 1, "request_id": "...", "lang": "tr", "count": 2 }
}422 · Invalid body
{
"error": { "code": "invalid_request", "message": "Provide between 1 and 50 words." },
"meta": { "lang": "en" }
}Response field reference
Every stable response variable is described below. Additive fields may appear later, so clients should ignore fields they do not recognize.
Vocabulary object
| Field | Type | Nullable | 描述 |
|---|---|---|---|
id | string | No | Stable URL-safe slug. |
word | string | No | Canonical English word. |
part_of_speech | string | 是的 | Grammatical class. |
level | string | 是的 | Learning difficulty or catalog level. |
definition | string | 是的 | Concise English definition. |
example | string | 是的 | Natural example sentence. |
phonetic | string | 是的 | Pronunciation transcription when available. |
translations | object<string,string> | No | Locale codes mapped to translations; may be empty. |
synonyms | string[] | No | Available synonyms. |
antonyms | string[] | No | Available antonyms. |
categories | string[] | No | Learning or semantic categories. |
media.image_url | URL string | 是的 | Learning image URL. |
media.audio_url | URL string | 是的 | Pronunciation audio URL. |
media.attribution | object | No | Required media attribution metadata. |
completeness | enum | No | catalog, translated, or enriched. |
Meta object
| Field | Type | When present | 描述 |
|---|---|---|---|
credits_used | integer | Metered responses | Credits charged by this request. |
request_id | UUID string | Metered success | Support and billing trace ID. |
lang | string | Always | Selected message locale. |
count | integer | List responses | Number of response items. |
next_cursor | string or null | Search | Next page cursor; null means final page. |
Error object
| Field | Type | 描述 |
|---|---|---|
error.code | string | Stable machine-readable code. |
error.message | string | Localized human-readable explanation. |
error.upgrade_url | string | Relative billing URL on a 402 result. |
meta.lang | string | Error-message locale. |
错误
| HTTP协议 | 代码 | 含义 | 客户行动 |
|---|---|---|---|
| 401 | invalid_api_key | 密钥丢失、格式错误、已撤销或无效。 | 检查承载标头或更换密钥。 |
| 402 | credits_exhausted | 该帐户缺少该操作的积分。 | 停止重试并引导客户进行计费。 |
| 404 | not_found | 请求的端点不可用。 | 检查路径和API版本。 |
| 404 | word_not_found | 请求的词汇条目不可用。 | 检查拼写或使用搜索。 |
| 422 | invalid_request | 参数或批处理主体无效。 | 重试之前更正请求。 |
| 405 | method_not_allowed | The endpoint does not accept the HTTP method. | Use the documented GET or POST method. |
| 413 | payload_too_large | The JSON request body exceeds 64 KB. | Reduce the batch body. |
| 415 | unsupported_media_type | The batch request is not JSON. | Send Content-Type: application/json. |
| 429 | rate_limit_exceeded | API 密钥每分钟超过 120 个请求。 | Wait for Retry-After. |
| 5xx | server_error | 意外的服务器端故障。 | 重试并退避;如果持续存在,请联系支持人员。 |
推荐的重试策略
不要重试 401, 402, or 404 自动。对于瞬态 5xx 响应,使用带抖动的指数退避和严格的重试上限。切勿创建无限制的重试循环,因为每个接受的经过身份验证的请求都可能会消耗积分。
JavaScript / Node.js
const response = await fetch('https://api.wordlyenglish.com/v1/account', {
headers: {
Authorization: `Bearer ${process.env.WORDLY_API_KEY}`,
Accept: 'application/json'
}
});
const body = await response.json();
if (!response.ok) {
throw new Error(`${body.error.code}: ${body.error.message}`);
}
console.log(body.data.credits_remaining);蟒蛇
import os
import requests
response = requests.get(
'https://api.wordlyenglish.com/v1/account',
headers={
'Authorization': f'Bearer {os.environ["WORDLY_API_KEY"]}',
'Accept': 'application/json',
},
timeout=15,
)
response.raise_for_status()
print(response.json()['data']['credits_remaining'])PHP
$curl = curl_init('https://api.wordlyenglish.com/v1/account');
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('WORDLY_API_KEY'),
'Accept: application/json',
],
]);
$body = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);
if ($status >= 400) {
throw new RuntimeException('Wordly API request failed');
}
$data = json_decode($body, true, flags: JSON_THROW_ON_ERROR);飞镖/颤振
不要在 Flutter 应用程序中发送 Wordly 密钥。该示例属于受信任的 Dart 后端或服务器功能。
final response = await http.get(
Uri.parse('https://api.wordlyenglish.com/v1/account'),
headers: {
'Authorization': 'Bearer ${Platform.environment['WORDLY_API_KEY']}',
'Accept': 'application/json',
},
);
final body = jsonDecode(response.body) as Map<String, dynamic>;
if (response.statusCode >= 400) {
throw Exception((body['error'] as Map)['code']);
}生产清单
- 通过受信任的后端代理 Wordly 请求。
- 设置连接和响应超时。
- 手柄
401,402,404, and5xx分别。 - Query
GET /v1/accountwhen your application needs the current balance. - 记录端点、状态、延迟和
request_id无需记录 API 密钥。 - 每个环境使用单独的密钥并定期轮换它们。
- Cache stable vocabulary responses in your backend when appropriate.
准备好提出您的第一个请求了吗?
创建帐户,验证您的电子邮件,并获得 50 个免费积分。
需要集成帮助吗?电子邮件 [email protected].