Call the Machine Translation Professional Edition to obtain translation results.
1. The API call limit is 50 queries per second (QPS). To increase the limit, contact us in DingTalk group 23369411.
2. The maximum length is 5,000 characters. If your text exceeds this limit, save it as a file and use Document Translation.
3. Before you use this API, make sure that you understand the billing methods and pricing of the Machine Translation Professional Edition.
Debugging
Request parameters
Name | Type | Required | Example value | Description |
Action | String | Yes | Translate | A required parameter. Set the value to Translate. |
FormatType | String | Yes | text | The format of the text to be translated. html: web page format. If you set this parameter to html, the source text and the translated text are processed as HTML. text: plain text format. If you set this parameter to text, the source text and the translated text are processed as plain text. |
Scene | String | Yes | title | Valid values: title, description, communication, medical, social, and finance. |
SourceLanguage | String | Yes | zh | The source language. |
SourceText | String | Yes | Hello | The content to be translated. |
TargetLanguage | String | Yes | en | The target language. |
Context | String | No | I ate bread at home this morning. | Contextual information. This parameter is optional. |
Scenario descriptions
This service offers different engines that are optimized for specific scenarios. Use the scene parameter to select an engine. The following are the valid values:
title: This engine is trained on Alibaba's E-commerce title data and is optimized for translating product titles.
description: This engine is trained on Alibaba's product description data and is optimized for translating detailed product descriptions.
communication: This engine provides high-quality translations for communication between buyers and sellers in E-commerce scenarios.
medical: This engine is trained on medical literature, terms, and drug information. It provides high-quality translations in medical scenarios.
social: This engine is designed for colloquial language and provides better translation results for social media content.
finance: This engine is designed for translations in the finance realm.
Returned data
Name | Type | Example | Description |
Code | Integer | 200 | The error code. |
Data | Struct | The returned data. | |
Translated | String | Hello | The translation result. |
WordCount | String | 10 | The total number of words. |
DetectedLanguage | String | zh | The code of the source language detected when the source language is set to auto. |
Message | String | success | The error message. |
RequestId | String | 86D18195-D89C-4C8C-9DC4-5FCE789CE6D5 | The request ID. |
Examples
Request example
http(s)://[Endpoint]/?Action=Translate
&FormatType=text
&Scene=title
&SourceLanguage=zh
&SourceText=Hello
&TargetLanguage=en
&<Common request parameters>For more information about common request parameters, see RPC invocation mechanism.
Successful response example
XML format
<TranslateResponse>
<Data>
<Translated>Hello</Translated>
</Data>
<RequestId>22A7F1D3-57AF-4F64-B2A6-5E1A180CF6B1</RequestId>
<Code>200</Code>
</TranslateResponse>JSON format
{
"TranslateResponse": {
"Data": {
"Translated": "Hello"
},
"RequestId": "22A7F1D3-57AF-4F64-B2A6-5E1A180CF6B1",
"Code": 200
}
}Error codes
HttpCode | Error code | Error message | Description |
101 | 10001 | The request has timed out. | The request timed out. |
102 | 10002 | A system error occurred. | A system error occurred. |
103 | 10003 | An error occurred while decoding the URL. Verify that the specified URL is encoded. | Failed to decode the source text. Check if the source text is URL-encoded. |
104 | 10004 | Some required parameters are missing. | A required parameter is missing. |
105 | 10005 | The specified language pair is not supported. | The language pair is not supported. |
106 | 10006 | An error occurred while detecting the language. | Failed to detect the language. |
107 | 10007 | An error occurred while translating. | Translation failed. |
108 | 10008 | The specified string is too long. | The character string is too long. |
199 | 19999 | An unknown error occurred. | An unknown error occurred. |
109 | 10009 | The RAM user is not authorized. | The RAM user is not authorized. |
110 | 10010 | The service is not activated for the account. | The service is not activated for the account. |
111 | 10011 | The service failed for the RAM user. | The service failed for the RAM user. |
112 | 10012 | The translation service call failed. | The translation service call failed. |
113 | 10013 | The service is not activated for the account or the account has an overdue payment. | The service is not activated for the account or the account has an overdue payment. |
For more error codes, visit the Error Center.