Translates text using Machine Translation Professional Edition, with specialized engines optimized for e-commerce, medical, social, and financial content.
The QPS (queries per second) limit for this API is 50. To request a higher limit, contact support via DingTalk group 21983957.
Before calling this API, review the billing methods and pricing for Professional Edition.2. Before you use this API, make sure that you understand the billing methods and pricing of the Machine Translation Professional Edition.
Debugging
Request parameters
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| Action | String | Yes | Translate | The operation to perform. Set to Translate. |
| FormatType | String | Yes | text | The format of the source and translated text. Valid values: html (HTML format — text is processed as markup), text (plain text — text is not processed as markup). |
| Scene | String | Yes | title | The translation scenario, which determines the engine used. Valid values: title, description, communication, medical, social, finance. See Scenarios for details. |
| SourceLanguage | String | Yes | zh | The source language code. |
| SourceText | String | Yes | Hello | The text to translate. |
| TargetLanguage | String | Yes | en | The target language code. |
Scenarios
Each scenario uses a separately trained engine optimized for that content type. Set the Scene parameter to one of the following values:
| Value | Scenario | Optimized for |
|---|---|---|
title | Product title | Short e-commerce product titles trained on Alibaba e-commerce data |
description | Product description | Detailed product descriptions trained on Alibaba product catalog data |
communication | E-commerce conversation | Buyer-seller messages in e-commerce contexts |
medical | Medical | Medical literature, terminology, and drug names |
social | Social | Colloquial and conversational text |
finance | Finance | Financial industry content |
Response elements
| Parameter | Type | Example | Description |
|---|---|---|---|
| Code | Integer | 200 | The HTTP status code. |
| Data | Struct | — | The response data. |
| Translated | String | Hello | The translated text. |
| WordCount | String | 10 | The word count of the source text. |
| DetectedLanguage | String | zh | The detected source language code. Returned only when SourceLanguage is set to auto. |
| Message | String | success | The response message. |
| RequestId | String | 86D18195-D89C-4C8C-9DC4-5FCE789CE6D5 | The request ID. |
Examples
Sample request
http(s)://[Endpoint]/?Action=Translate
&FormatType=text
&Scene=title
&SourceLanguage=en
&SourceText=Hello
&TargetLanguage=zh
&<Common request parameters>Sample success response — XML
<TranslateResponse>
<Data>
<Translated>Hello</Translated>
</Data>
<RequestId>22A7F1D3-57AF-4F64-B2A6-5E1A180CF6B1</RequestId>
<Code>200</Code>
</TranslateResponse>Sample success response — JSON
{
"TranslateResponse": {
"Data": {
"Translated": "Hello"
},
"RequestId": "22A7F1D3-57AF-4F64-B2A6-5E1A180CF6B1",
"Code": 200
}
}Error codes
| HTTP status code | Error code | Error message | Description |
|---|---|---|---|
| 101 | 10001 | The request has timed out. | The request timed out. |
| 102 | 10002 | A system error occurred. | System error. |
| 103 | 10003 | An error occurred while decoding the URL. Verify that the specified URL is encoded. | The source text is not URL encoded. |
| 104 | 10004 | Some required parameters are missing. | The application ID is not specified. |
| 105 | 10005 | The specified language pair is not supported. | The language pair is not supported. |
| 106 | 10006 | An error occurred while detecting the language. | Language detection failed. |
| 107 | 10007 | An error occurred while translating. | Translation failed. |
| 108 | 10008 | The specified string is too long. | The source text exceeds the maximum length. |
| 109 | 10009 | The RAM user has no permissions. | The RAM user does not have the required permissions. |
| 110 | 10010 | The account does not activate the service. | Machine Translation is not activated for this account. |
| 111 | 10011 | The sub-account service failed. | The RAM user service failed. |
| 112 | 10012 | Translation service call failed | The translation service call failed. |
| 113 | 10013 | The account service is not activated or the payment is overdue. | The service is not activated or the account has an overdue payment. |
| 199 | 19999 | An unknown error occurred. | An unknown error occurred. |
For the full list of error codes, see Service error codes.
For more error codes, visit the Error Center.