Machine batch translation, which supports multiple text segments for translation.

1. The QPS limit for calling the interface is 50. If you have any expansion requirements, please contact us DingTalk group number: 21983957

2. The maximum length of a single character in batch translation is 1000 characters, and a maximum of 50 characters can be translated at a time.Please ensure that you have fully understood the charging methods and prices of universal version and professional translation products before using this interface.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

ParameterTypeRequiredExampleMessage
ActionStringYesGetBatchTranslate

The operation that you want to perform. Set the value to GetBatchTranslate.

FormatTypeStringYestext

The format of the translated text. html (web page format. Setting this parameter will process the text to be translated and the translated text in html format), text (text format. If you set this parameter, the text to be translated and the translated results will not be text format processed, but will be processed as pure text format.

TargetLanguageStringYeszh

Reference language code

SourceLanguageStringYesen

Reference language code

SceneStringYesgeneral
  • Scenarios supported by the professional edition: product title (title), product description (description), product communication (communication), medical (medical), and social (social)
  • Scenarios supported by the general version: general
ApiTypeStringYestranslate_standard
  • version type, you must select a version
  • General Version: translate_standard
  • Professional version: translate_ecommerce
SourceTextStringYes{"11":"hello boy","12":"go home","13":"we can"}

json data format

Key: Unique tag id, used to get the corresponding id for the translation result, corresponding to the original text

value: the content to be translated

The following code shows the format of the event parameter:

{ "11": "hello boy", "12": "go home", "13": "we can"}
Note The number of pieces to be translated cannot exceed 50
Note The number of characters in a single translation cannot exceed 1000 characters.
Note key does not count the translated characters
Note In the content to be translated, characters are included in punctuation, spaces, and html tags

Response parameters

ParameterTypeExampleMessage
CodeInteger200

Error codes

MessageStringsuccess

The message that is returned.

RequestIdString86D18195-D89C-4C8C-9DC4-5FCE789CE6D5

The unique ID of the request, which is used for subsequent troubleshooting.

TranslatedListArray of Object[{"code":"200","wordCount":"9","detectedLanguage": "en","index":"11","translated":"Hello Boy"},{"code":"200","wordCount":"7","detectedLanguage": "en","index":"12","translated":"Go Home"},{"code":"200","wordCount":"6","detectedLanguage": "en","index":"13","translated":"We can"}]

The returned result is in the JSON format.

Code: status code of a single translation

wordCount: the number of characters in the original text.

index: key when entering the parameter, unique id, used to correspond to the original text

detectedLanguage: the source language code after language identification when the source language is passed into auto

translated: the translation result.

[ { "code": "200", "wordCount": "9", "detectedLanguage": "en","index": "11", "translated": "Hello boy" }, { "code": "200", "wordCount": "7","detectedLanguage": "en", "index": "12", "translated": "Go home" }, { "code": "200", "wordCount": "6","detectedLanguage": "en", "index": "13", "translated": "We can" }]

Examples

Sample requests

http(s)://[Endpoint]/?Action=GetBatchTranslate
&ApiType=translate_standard
&FormatType=text    
&Scene=general
&SourceLanguage=en
&SourceText={"11":"hello boy","12":"go home","13":"we can"}
&TargetLanguage=zh
&<Common request parameters>

Sample success response

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<Message>success</Message>
<RequestId>86D18195-D89C-4C8C-9DC4-5FCE789CE6D5</RequestId>
<TranslatedList>[{"code":"200","wordCount":"9","index":"11","translated":"Hello Boy"},{"code":"200","wordCount":"7","index":"12","translated":"Go Home"},{"code":"200","wordCount":"6","index":"13","translated":"We can"}]</TranslatedList>
<Code>200</Code>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "Message" : "success",
  "RequestId" : "86D18195-D89C-4C8C-9DC4-5FCE789CE6D5",
  "TranslatedList" : "[{" code\":\"200\",\"wordCount\":\"9\",\"index\":\"11\",\"translated\":\" Hello boy \"},{\\" code\":\"200\",\"wordCount\":\"7\", "index" : "12", "translated" : "Go home" },{" code " : " 200 "," wordCount " : " 6 "," index " : " 13 "," translated " : " We can "}]",
  "Code" : "200"
}

Error codes

HttpCodeError codeError messageRemarks
110System.AccountNotActivatedThe account has not activated the service.The account does not activate the service.
199System.unknownErrorAn unknown error occurred.The error message returned because an unknown error has occurred.
111System.SubServiceFailedSub-account service failed.Sub-account service failure
101System.RequestTimeOutThe request has timed out.The request timed out.
112System.TranslateServiceCallFailedFailed to call the translation service.Translation service call failed
102System.ErrorA system error occurred.System error.
113System.AccountNotActivatedOrInArrearsThe service is not activated or the account has an outstanding balance.The account service is not activated or the payment is overdue.
103System.UrlDecodingErrorAn error occurred while decoding the URL. Verify that the specified URL is encoded.URL encoding error
104System.ParameterErrorSome required parameters are missing.The error message returned because a specified parameter is invalid.
105System.LanguageNotSupportedThe specified language pair is not supported.This language is not supported.
106System.LanguageDetectErrorAn error occurred while detecting the language.Language recognition error
107System.TranslateErrorAn error occurred while translating.Translation error
108System.StringTooLongThe maximum length of the specified string is exceeded.characters too long
109System.SubNotPermissionThe sub account is not authorized to perform the operation.The RAM user has no permissions.
109System.subNotPermissionThe sub-account is not authorized to perform the operation.The RAM user has no permissions.

For a list of error codes, see Service error codes.