开发者文档

使用 Wordly API 构建。

使用服务器端 API 密钥,发出 HTTPS 请求,并通过可预测的基于信用的计费模型跟踪每个呼叫。该参考记录了当前生产中可用的端点,并明确标记了仍在准备中的端点。

API version v1格式 JSON交通 仅 HTTPS自由余额 50 credits开放API 下载架构Postman CollectionPostman Environment

快速入门

创建一个免费帐户,使用六位数代码验证您的电子邮件,然后复制开发人员仪表板中显示的 API 密钥。

  1. 1
    创建帐户

    仅使用电子邮件地址和密码进行注册。

  2. 2
    验证您的电子邮件

    输入发送者发送的代码 [email protected]. Verification grants 50 free credits.

  3. 3
    存储您的 API 密钥

    复制生成的 wly_live_... key 并将其保存在服务器端环境变量中。

  4. 4
    提出测试请求

    调用账户端点验证身份验证并查看剩余余额。

壳牌
curl "https://api.wordlyenglish.com/v1/account" \
  -H "Authorization: Bearer $WORDLY_API_KEY" \
  -H "Accept: application/json"
200 response
{
  "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
不要公开 API 密钥。

切勿将实时密钥放置在浏览器 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/status0直播
GET /v1/account0直播
GET /v1/words/{word}1–5直播
GET /v1/words/search1直播
GET /v1/words/random1 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 并且不处理该操作。

402 response
{
  "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.

Cache behavior

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" }
}
Possible results200 Service is reachable.405 Method is not GET.429 IP request limit exceeded.
获取/v1/accountLive · 0 credits

Validates 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" }
}
Possible results200 Key accepted and balance returned.401 Missing, invalid, revoked, or suspended key.429 Rate limit exceeded.

词汇端点

20,000+ catalog entries are live.

每条记录都报告其 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 credits

Lists all supported interface and API-message locales. Vocabulary translations are returned only when a record contains them.

Query parameters

名称Type必填Rules描述
langstringNoSupported locale codeLanguage 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" }
}
Possible results200 Locale list returned.405 Method is not GET.429 IP request limit exceeded.
获取/v1/words/{word}Live · 1–5 credits

Returns one exact vocabulary record. Catalog and translated records cost 1 credit; enriched records cost 5 credits.

Parameters

名称LocationType必填Rules and meaning
wordPathstring是的Exact word or slug; maximum 120 characters. URL-encode special characters.
languagesQuerystringNoComma-separated translation codes, for example tr,de,fr.
langQuerystringNoHuman-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" }
}
Possible results200 Exact record returned.401 Invalid API key.402 Insufficient credits.404 Word not found.422 Word too long.429 Rate limit exceeded.
获取/v1/words/randomLive · 1 credit per requested slot

Returns random active words for quizzes, discovery feeds, and practice sessions.

Query parameters

名称Type必填Default / limit描述
countintegerNo1; min 1, max 20Requested slots and credit cost.
levelstringNoExact valueLevel filter.
part_of_speech / posstringNoExact valueGrammatical-class filter.
categorystringNoExact valueCategory filter.
languagesstringNoComma-separatedTranslations 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 }
}
Possible results200 Random array returned.401 Invalid API key.402 Balance below requested count.429 Rate limit exceeded.
POST/v1/words/batchLive · calculated

Looks 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

FieldType必填Rules描述
wordsstring[]是的1–50 items; each max 120 charsWords to resolve; duplicates are normalized and removed.
languagesstring[]NoSupported locale codesTranslations 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" }
}
Possible results200 Ordered results.401 Invalid API key.402 Insufficient credits.413 Body over 64 KB.415 Content-Type is not JSON.422 Invalid words array.429 Rate limit exceeded.

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

FieldTypeNullable描述
idstringNoStable URL-safe slug.
wordstringNoCanonical English word.
part_of_speechstring是的Grammatical class.
levelstring是的Learning difficulty or catalog level.
definitionstring是的Concise English definition.
examplestring是的Natural example sentence.
phoneticstring是的Pronunciation transcription when available.
translationsobject<string,string>NoLocale codes mapped to translations; may be empty.
synonymsstring[]NoAvailable synonyms.
antonymsstring[]NoAvailable antonyms.
categoriesstring[]NoLearning or semantic categories.
media.image_urlURL string是的Learning image URL.
media.audio_urlURL string是的Pronunciation audio URL.
media.attributionobjectNoRequired media attribution metadata.
completenessenumNocatalog, translated, or enriched.

Meta object

FieldTypeWhen present描述
credits_usedintegerMetered responsesCredits charged by this request.
request_idUUID stringMetered successSupport and billing trace ID.
langstringAlwaysSelected message locale.
countintegerList responsesNumber of response items.
next_cursorstring or nullSearchNext page cursor; null means final page.

Error object

FieldType描述
error.codestringStable machine-readable code.
error.messagestringLocalized human-readable explanation.
error.upgrade_urlstringRelative billing URL on a 402 result.
meta.langstringError-message locale.

错误

HTTP协议代码含义客户行动
401invalid_api_key密钥丢失、格式错误、已撤销或无效。检查承载标头或更换密钥。
402credits_exhausted该帐户缺少该操作的积分。停止重试并引导客户进行计费。
404not_found请求的端点不可用。检查路径和API版本。
404word_not_found请求的词汇条目不可用。检查拼写或使用搜索。
422invalid_request参数或批处理主体无效。重试之前更正请求。
405method_not_allowedThe endpoint does not accept the HTTP method.Use the documented GET or POST method.
413payload_too_largeThe JSON request body exceeds 64 KB.Reduce the batch body.
415unsupported_media_typeThe batch request is not JSON.Send Content-Type: application/json.
429rate_limit_exceededAPI 密钥每分钟超过 120 个请求。Wait for Retry-After.
5xxserver_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, and 5xx 分别。
  • Query GET /v1/account when your application needs the current balance.
  • 记录端点、状态、延迟和 request_id 无需记录 API 密钥。
  • 每个环境使用单独的密钥并定期轮换它们。
  • Cache stable vocabulary responses in your backend when appropriate.

准备好提出您的第一个请求了吗?

创建帐户,验证您的电子邮件,并获得 50 个免费积分。

创建免费帐户

需要集成帮助吗?电子邮件 [email protected].