Text translation

Important

Support for v1 is discontinued as of February 2019. The methods listed below will be deprecated. Please use v2.

Translates the source text into 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.
The ID of your folder.

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"
        }
    ]
}