API Attività di Traduzione
Testo tradotto
Traduci il testo e restituisci simultaneamente i risultati della traduzione.
- Indirizzo completo
- https://otranslator.com/api/v1/translation/translateTexts
- Autenticazione
- È necessario passare la API Key nell'intestazione della richiesta Authorization
- Content-Type
- application/json
- Formato errato
- { "error": "Invalid API key." }
Note importanti
Questa interfaccia salva temporaneamente il testo inserito come documento JSON e lo elabora in modo sincrono, adatta per la traduzione istantanea di piccoli lotti di testo.
Il saldo crediti dell'account richiede almeno 2 credits. Se il costo reale supera il saldo, l'interfaccia restituisce taskId e price e segnala saldo insufficiente.
Esempio
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}'Parametri della Richiesta
| Parametri | Tipo | Predefinito | Descrizione | Esempio |
|---|---|---|---|---|
| *texts | String[] | - | Testo da tradurre | - |
| *fromLang | String | - |
| - |
| *toLang | String | - |
| - |
| model | String | - |
| - |
| fileDescription | String | - | Descrizione documento: migliora la qualità della traduzione fornendo informazioni aggiuntive, come l'inserimento di ulteriori informazioni di contesto del documento e altri requisiti di traduzione, ecc. | - |
Risposta
| Parametri | Tipo | Predefinito | Descrizione | Esempio |
|---|---|---|---|---|
| taskId | String | - | ID attività | - |
| translatedTexts | String[] | - | Testo tradotto | - |
| price | Integer | - | Numero totale di Credits richiesti per la traduzione completa | - |
| usedCredits | Integer | - | Numero di crediti utilizzati dall'attività di traduzione | - |
Errori comuni
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.