API Sarcină de Traducere
Traducere text
Traduceți textul și primiți rezultatele traducerii în mod sincronizat.
- Adresă completă
- https://otranslator.com/api/v1/translation/translateTexts
- Autentificare
- Este necesar să transmiteți API Key în headerul de cerere Authorization
- Content-Type
- application/json
- Format greșit
- { "error": "Invalid API key." }
Precauții
Această interfață va salva temporar textul transmis ca document JSON și îl va procesa sincron, fiind potrivită pentru traducerea instantanee a textelor în loturi mici.
Soldul de credite al contului trebuie să fie de cel puțin 2 credits. Dacă costul real depășește soldul, interfața va returna taskId și price și va afișa mesaj de sold insuficient.
Exemplu
1curl -X POST 'https://otranslator.com/api/v1/translation/translateTexts' \
2--header 'Authorization: [yourSecretKey]' \
3--header 'Content-Type: application/json' \
4--data '{
5 "texts": [
6 "string"
7 ],
8 "fromLang": "[string]",
9 "toLang": "[string]"
10}'Parametrii de Cerere
| Parametri | Tip | Implicit | Descriere | Exemplu |
|---|---|---|---|---|
| *texts | String[] | - | Textul care necesită traducere | - |
| *fromLang | String | - |
| - |
| *toLang | String | - |
| - |
| model | String | - |
| - |
| fileDescription | String | - | Descrierea documentului - prin furnizarea de informații suplimentare se îmbunătățește calitatea traducerii, de exemplu prin adăugarea de informații contextuale suplimentare ale documentului și alte cerințe de traducere etc. | - |
Răspuns
| Parametri | Tip | Implicit | Descriere | Exemplu |
|---|---|---|---|---|
| taskId | String | - | ID sarcină | - |
| translatedTexts | String[] | - | Textul tradus | - |
| price | Integer | - | Numărul total de credite necesare pentru traducere | - |
| usedCredits | Integer | - | Numărul de Credits utilizate de sarcina de traducere | - |
Erori frecvente
401 Missing API key.
The Authorization request header is required.
401 Invalid API key.
The API key does not exist, has been deleted, or is no longer valid.
402 Insufficient credits balance.
The account does not have enough credits to translate the texts.
400 Missing required parameter: fromLang.
Provide fromLang using a language returned by /api/v1/languages.
400 Missing required parameter: toLang.
Provide toLang using a language returned by /api/v1/languages.
400 Missing required parameter: texts.
Provide a non-empty texts array.
400 Failed to translate texts.
The text translation task could not be processed.