เอกสารสำหรับนักพัฒนา

สร้างด้วย Wordly API

ใช้คีย์ API ฝั่งเซิร์ฟเวอร์ สร้างคำขอ HTTPS และติดตามทุกการโทรผ่านรูปแบบการเรียกเก็บเงินตามเครดิตที่คาดการณ์ได้ ข้อมูลอ้างอิงนี้บันทึกตำแหน่งข้อมูลที่มีอยู่ในการผลิตในปัจจุบัน และทำเครื่องหมายตำแหน่งข้อมูลอย่างชัดเจนที่ยังคงถูกจัดเตรียมไว้

API version เวอร์ชัน 1รูปแบบ เจสันขนส่ง HTTPS เท่านั้นยอดคงเหลือฟรี 50 creditsOpenAPI ดาวน์โหลดสคีมาPostman CollectionPostman Environment

เริ่มต้นอย่างรวดเร็ว

สร้างบัญชีฟรี ยืนยันอีเมลของคุณโดยใช้รหัสหกหลัก และคัดลอกคีย์ API ที่แสดงครั้งเดียวในแดชบอร์ดนักพัฒนาซอฟต์แวร์ของคุณ

  1. 1
    สร้างบัญชี

    ลงทะเบียนด้วยที่อยู่อีเมลและรหัสผ่านเท่านั้น

  2. 2
    ยืนยันอีเมลของคุณ

    ใส่รหัสที่ส่งมาโดย [email protected]. Verification grants 50 free credits.

  3. 3
    จัดเก็บคีย์ API ของคุณ

    คัดลอกที่สร้างขึ้น wly_live_... คีย์และเก็บไว้ในตัวแปรสภาพแวดล้อมฝั่งเซิร์ฟเวอร์

  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 พื้นฐานที่มีเวอร์ชันต่อไปนี้:

URL ฐานhttps://api.wordlyenglish.com/v1

การตอบสนองที่ไม่สมบูรณ์หรือการเปลี่ยนแปลงพฤติกรรมจะใช้เวอร์ชันเส้นทางใหม่ อาจมีการแนะนำช่องเพิ่มเติมภายใน v1, so clients should ignore response properties they do not recognize.

การรับรองความถูกต้อง

ตำแหน่งข้อมูลที่ได้รับการตรวจสอบสิทธิ์ต้องใช้คีย์ API ใน HTTP Authorization ส่วนหัวโดยใช้โครงการ Bearer

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

ส่งคืนอินเทอร์เฟซที่รองรับและตำแหน่งข้อความ API ทั้งหมด 30 รายการ การแปลคำศัพท์จะถูกส่งกลับเมื่อมีให้เท่านั้น ตำแหน่งข้อมูลนี้เป็นสาธารณะและมีค่าใช้จ่ายเป็นศูนย์เครดิต

ขีดจำกัดอัตรา

คีย์ 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คีย์หายไป มีรูปแบบไม่ถูกต้อง ถูกเพิกถอน หรือไม่ใช้งานตรวจสอบส่วนหัวของ Bearer หรือเปลี่ยนกุญแจ
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_exceededคีย์ API เกิน 120 คำขอต่อนาทีWait for Retry-After.
5xxserver_errorความล้มเหลวฝั่งเซิร์ฟเวอร์ที่ไม่คาดคิดลองอีกครั้งโดยถอยกลับ ติดต่อฝ่ายสนับสนุนหากยังคงมีอยู่

นโยบายการลองใหม่ที่แนะนำ

อย่าลองอีกครั้ง 401, 402, or 404 โดยอัตโนมัติ สำหรับชั่วคราว 5xx การตอบกลับ ให้ใช้การถอยกลับแบบเอกซ์โปเนนเชียลโดยมีการกระวนกระวายใจและจำกัดการลองใหม่อย่างเข้มงวด อย่าสร้างการวนซ้ำแบบไม่มีขอบเขต เนื่องจากคำขอตรวจสอบสิทธิ์ที่ยอมรับแต่ละรายการอาจใช้เครดิต

จาวาสคริปต์ / 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);

โผ / กระพือ

อย่าจัดส่งคีย์ Wordly ภายในแอปพลิเคชัน Flutter ตัวอย่างนี้อยู่ในแบ็กเอนด์ 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']);
}

รายการตรวจสอบการผลิต

  • Proxy 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].