Translation Task API
Přeložený text
Přeložte text a synchronně získejte výsledky překladu.
- Úplná adresa
- https://dltranslator.com/api/v1/translation/translateTexts
- Ověření
- V hlavičce požadavku Authorization je nutné předat API Key
- Content-Type
- application/json
- Chybný formát
- { "error": "Invalid API key." }
Upozornění
Rozhraní dočasně uloží vložený text jako dokument JSON a zpracuje jej synchronně, vhodné pro okamžitý překlad malého množství textu.
Zůstatek bodů na účtu musí být alespoň 2 credits. Pokud skutečné náklady překročí zůstatek, rozhraní vrátí taskId a price a upozorní na nedostatečný zůstatek.
Příklad
1curl -X POST 'https://dltranslator.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}'Parametry požadavku
| Parametry | Typ | Výchozí | Popis | Příklad |
|---|---|---|---|---|
| *texts | String[] | - | Text k překladu | - |
| *fromLang | String | - |
| - |
| *toLang | String | - |
| - |
| model | String | - |
| - |
| fileDescription | String | - | Popis dokumentu - zlepšuje kvalitu překladu poskytnutím dodatečných informací, například přidáním kontextových informací o dokumentu a dalších překladových požadavků atd. | - |
Odpověď
| Parametry | Typ | Výchozí | Popis | Příklad |
|---|---|---|---|---|
| taskId | String | - | ID úlohy | - |
| translatedTexts | String[] | - | Přeložený text | - |
| price | Integer | - | Celkový počet kreditů potřebný pro překlad | - |
| usedCredits | Integer | - | Počet kreditů použitých překladovou úlohou | - |
Běž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.