How to translate text
Written by
Warning
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 en ). 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 en ). |
format |
Text format. Possible values:
|
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=hello world" \
--data-urlencode "text=good morning" \
"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"
}
]
}