Skip to main content

Unlisted page
This page is unlisted. Search engines will not index it, and only users having a direct link can access it.

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

ParameterTypeRequiredDescription
textStringYesThe text to translate. Maximum 1,000 characters.
sourceLanguageStringNoLanguage code of the source language. Defaults to auto. Note: When Cantonese is the source language, auto is not supported.
targetLanguageStringYesLanguage 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:

FieldTypeRequiredDescription
codeNumberYesReturn code. 200 indicates success.
translatedStringNoThe translated text.

Response example

JSON
{
"code": 200,
"translated": "Hello world."
}