Text translation
The Platform Chat API provides a text translation endpoint that translates text into a specified target language. This endpoint supports translation between multiple languages. For supported languages, see Supported languages and codes.
Request
POST: https://[Base URL](/platform-chat-api/base-url)/v3/translate.json
Rate limit: 10 requests per second
Signature: All API requests require signature verification. See API request signature.
Request body
Content type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
text | String | Yes | The text to translate. Maximum 1,000 characters. |
sourceLanguage | String | No | Language code of the source language. Defaults to auto. Note: When Cantonese is the source language, auto is not supported. |
targetLanguage | String | Yes | Language code of the target language. Defaults to zh. |
Request example
HTTP
POST /v3/translate.json HTTP/1.1
Host: api.sg-light-api.com
App-Key: uwd1c0sxdlx2
Nonce: 14314
Timestamp: 1408710653491
Signature: 45beb7cc7307889a8e711219a47b7cf6a5b000e8
Content-Type: application/json
X-Request-ID: XXXXXXXXXXXXXXXXXXXXXXXXXXXX (max length 36)
{
"text": "你好世界",
"targetLanguage": "en",
"sourceLanguage": "auto"
}
Response
The response body contains a JSON object with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
code | Number | Yes | Return code. 200 indicates success. |
translated | String | No | The translated text. |
Response example
JSON
{
"code": 200,
"translated": "Hello world."
}