البناء باستخدام Wordly API.
استخدم مفتاح واجهة برمجة التطبيقات (API) من جانب الخادم، وقم بإجراء طلبات HTTPS، وتتبع كل مكالمة من خلال نموذج فوترة قائم على الائتمان يمكن التنبؤ به. يوثق هذا المرجع نقاط النهاية المتوفرة حاليًا في الإنتاج ويحدد بوضوح نقاط النهاية التي لا تزال قيد الإعداد.
بداية سريعة
أنشئ حسابًا مجانيًا، وتحقق من بريدك الإلكتروني باستخدام الرمز المكون من ستة أرقام، وانسخ مفتاح واجهة برمجة التطبيقات الذي يظهر مرة واحدة في لوحة تحكم المطور.
- 1إنشاء حساب
سجل باستخدام عنوان البريد الإلكتروني وكلمة المرور فقط.
- 2تحقق من بريدك الإلكتروني
أدخل الرمز الذي أرسلته
[email protected]. التحقق يمنح 50 ساعة معتمدة مجانية. - 3قم بتخزين مفتاح API الخاص بك
انسخ ما تم إنشاؤه
wly_live_...المفتاح والاحتفاظ به في متغير البيئة من جانب الخادم. - 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لذا يجب على العملاء تجاهل خصائص الاستجابة التي لا يتعرفون عليها.
المصادقة
تتطلب نقاط النهاية التي تمت مصادقتها مفتاح API في HTTP Authorization رأس باستخدام مخطط Bearer.
Authorization: Bearer wly_live_your_api_keyلا تضع أبدًا مفتاحًا مباشرًا في متصفح JavaScript أو مستودعات Git العامة أو لقطات الشاشة أو السجلات أو تطبيقات الهاتف المحمول الموزعة. اتصل بـ Wordly API من الواجهة الخلفية لديك واسمح لتطبيقك بالتواصل مع تلك الواجهة الخلفية.
رسائل API المترجمة
اضبط لغة الرد باستخدام ?lang=tr أو المعيار Accept-Language header. معلمات الاستعلام لها الأسبقية. تعلن كل استجابة JSON عن اللغة المحددة فيها Content-Language و meta.lang. تظل رموز الأخطاء مستقرة في اللغة الإنجليزية للتعامل مع البرامج؛ يتم ترجمة الرسالة التي يمكن قراءتها بواسطة الإنسان فقط.
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 لكل كلمة | مباشر |
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
قم بإنشاء مفاتيح منفصلة للتطوير والتدريج والإنتاج. يقوم 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أو enriched. يتم إرجاع الحقول غير المتوفرة كـ null أو كائن فارغ بدلاً من البيانات المخترعة.
GET /v1/words/{word}
إرجاع مطابقة تامة للكلمة. استخدم languages=tr,de,fr لإرجاع الترجمات المطلوبة فقط. تكلفة الكتالوج أو السجلات المترجمة هي رصيد واحد؛ تكلف الملفات الشخصية المخصبة بالكامل 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، و cursor. تتراوح الحدود من 1 إلى 50. اجتياز 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أو category. كل فتحة يتم إرجاعها تكلف رصيدًا واحدًا.
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 الثلاثين. يتم إرجاع ترجمات المفردات فقط عندما تكون متاحة. نقطة النهاية هذه عامة ولا تكلف أية أرصدة.
حد المعدل
يقتصر كل مفتاح API على 120 طلبًا مقبولاً في الدقيقة الواحدة. تشمل الردود X-RateLimit-Limit و X-RateLimit-Remaining. أ 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مباشر · رصيد واحد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أو 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 | مفتاح مفقود أو مشوه أو ملغى أو غير نشط. | تحقق من رأس Bearer أو استبدل المفتاح. |
| 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 طلبًا في الدقيقة. | انتظر Retry-After. |
| 5xx | server_error | فشل غير متوقع من جانب الخادم. | أعد المحاولة مع التراجع؛ اتصل بالدعم إذا كان مستمرًا. |
سياسة إعادة المحاولة الموصى بها
لا تقم بإعادة المحاولة 401, 402أو 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، و5xxبشكل منفصل. - 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].