Text translation

Translates the source text to the specified language.

Request

POST https://translate.api.cloud.yandex.net/translate/v1/translate

Parameters in the request body

All parameters must be URL-encoded. The maximum size of the POST request body is 30 KB.

Parameter Description
text Required parameter.
UTF-8 encoded text to translate.
You can use multiple text parameters in a request.
source Language of the source text.
Set as a two-letter language code according to ISO-639-1 (for example, ru). If this parameter is omitted, the service tries to detect the source language automatically.
target Required parameter.
Translation direction.
Set as a two-letter language code according to ISO-639-1 (for example en).
format Text format.
Possible values:
  • plain — Text without markup (default value).
  • html — Text in HTML format.
folderId Required parameter.
ID of your folder.
For more information about how to find the folder ID, see the section Authorization in the API.

Response

The response is returned in JSON format.

{
    "translations": [
        {"text": <text translation>},
        ...
    ]
}

Examples

Sample request

export FOLDER_ID=<folder id>
export TOKEN=<IAM-token>
curl -X POST \
     -H "Authorization: Bearer ${TOKEN}" \
     -d "folderId=${FOLDER_ID}&target=en" \
     --data-urlencode "text=привет мир" \
     --data-urlencode "text=доброе утро" \
     "https://translate.api.cloud.yandex.net/translate/v1/translate"

Response example

The response is returned in JSON format.

{
    "translations": [
        {
            "text": "Hello world"
        },
        {
            "text": "good morning"
        }
    ]
}