Translation Task API
Translation text
Translate text and return translation results synchronously.
- Complete address
- https://otranslator.com/api/v1/translation/translateTexts
- Authentication
- API Key needs to be passed in the Authorization request header
- Content-Type
- application/json
- Invalid format
- { "error": "Invalid API key." }
Precautions
This API temporarily saves the input text as a JSON document and processes it synchronously, suitable for immediate translation of small batches of text.
Account credit balance must be at least 2 credits. If actual cost exceeds balance, the API will return taskId and price, and prompt insufficient balance.
Example
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}'Request Parameters
| Parameters | Type | Default | Description | Example |
|---|---|---|---|---|
| *texts | String[] | - | Text to be translated | - |
| *fromLang | String | - |
| - |
| *toLang | String | - |
| - |
| model | String | - |
| - |
| fileDescription | String | - | Document description. Improve translation quality by providing additional information, such as extra document background information and other translation requirements. | - |
Response
| Parameters | Type | Default | Description | Example |
|---|---|---|---|---|
| taskId | String | - | Task ID | - |
| translatedTexts | String[] | - | Translated text | - |
| price | Integer | - | Total Credits required for the complete translation | - |
| usedCredits | Integer | - | Number of credits used by the translation task | - |
Common Errors
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.