Translation Task API
Preložiť text
Preložiť text a synchronizovane vrátiť výsledky prekladu.
- Úplná adresa
- https://otranslator.com/api/v1/translation/translateTexts
- Autentifikácia
- Je potrebné poskytnúť API Key v hlavičke požiadavky Authorization
- Content-Type
- application/json
- Chybný formát
- { "error": "Invalid API key." }
Upozornenia
Toto rozhranie dočasne uloží vstupný text ako JSON dokument a synchrónne ho spracuje, je vhodné pre okamžitý preklad malého množstva textu.
Zostatok kreditov na účte musí byť aspoň 2 credits. Ak skutočné náklady presiahnu zostatok, rozhranie vráti taskId a price a oznámi nedostatok zostatku.
Príklad
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}'Parametre požiadavky
| Parametre | Typ | Predvolené | Popis | Príklad |
|---|---|---|---|---|
| *texts | String[] | - | Text na preklad | - |
| *fromLang | String | - |
| - |
| *toLang | String | - |
| - |
| model | String | - |
| - |
| fileDescription | String | - | Popis dokumentu, zlepšenie kvality prekladu poskytnutím dodatočných informácií, napríklad pridanie kontextových informácií o dokumente a ďalších požiadaviek na preklad atď. | - |
Odpoveď
| Parametre | Typ | Predvolené | Popis | Príklad |
|---|---|---|---|---|
| taskId | String | - | ID úlohy | - |
| translatedTexts | String[] | - | Preložený text | - |
| price | Integer | - | Celkový počet kreditov potrebných na preklad | - |
| usedCredits | Integer | - | Počet kreditov použitých prekladovou úlohou | - |
Bežné chyby
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.