API Zadania Tłumaczenia
Tłumaczenie tekstu
Przetłumacz tekst i synchronicznie zwróć wyniki tłumaczenia.
- Pełny adres
- https://otranslator.com/api/v1/translation/translateTexts
- Uwierzytelnienie
- Należy przekazać API Key w nagłówku żądania Authorization
- Content-Type
- application/json
- Nieprawidłowy format
- { "error": "Invalid API key." }
Uwagi
Ten interfejs tymczasowo zapisuje przekazany tekst jako dokument JSON i przetwarza go synchronicznie, nadaje się do natychmiastowego tłumaczenia małych partii tekstu.
Saldo punktów na koncie musi wynosić co najmniej 2 credits. Jeśli rzeczywisty koszt przekroczy saldo, interfejs zwróci taskId oraz price i wyświetli komunikat o niewystarczającym saldzie.
Przykład
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}'Parametry żądania
| Parametry | Typ | Domyślny | Opis | Przykład |
|---|---|---|---|---|
| *texts | String[] | - | Tekst do przetłumaczenia | - |
| *fromLang | String | - |
| - |
| *toLang | String | - |
| - |
| model | String | - |
| - |
| fileDescription | String | - | Opis dokumentu - poprzez dostarczenie dodatkowych informacji można poprawić jakość tłumaczenia, na przykład dodając dodatkowe informacje kontekstowe o dokumencie i inne wymagania dotyczące tłumaczenia itp. | - |
Odpowiedź
| Parametry | Typ | Domyślny | Opis | Przykład |
|---|---|---|---|---|
| taskId | String | - | ID zadania | - |
| translatedTexts | String[] | - | Przetłumaczony tekst | - |
| price | Integer | - | Całkowita liczba kredytów potrzebnych do tłumaczenia | - |
| usedCredits | Integer | - | Liczba punktów Credits wykorzystanych przez zadanie tłumaczenia | - |
Typowe błędy
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.