Translating a text
JSON and JSONP interfaces
The response is returned in JSON format. If the callback
parameter is set, the JSON object is wrapped in a function. The function name is specified in this parameter (JSONP).
Request syntax
https://translate.yandex.net/api/v1.5/tr.json/translate
? [key=<API key>]
& [text=<text to translate>]
& [lang=<translation direction>]
& [format=<text format>]
& [options=<translation options>]
& [callback=<callback function name>]
key | |
text | The text to be translated. You can use several Attention. For the source text, use the URL encoding. Limitations:
|
lang | Translation direction. Can be set using one of the following methods:
|
format | Text format. Possible values:
|
options | Currently, the only available option is to include the automatically defined source language in the response. This corresponds to the parameter value If the source language is set explicitly, meaning the |
callback | Name of the callback function. Used to get a JSONP response. |
key | |
text | The text to be translated. You can use several Attention. For the source text, use the URL encoding. Limitations:
|
lang | Translation direction. Can be set using one of the following methods:
|
format | Text format. Possible values:
|
options | Currently, the only available option is to include the automatically defined source language in the response. This corresponds to the parameter value If the source language is set explicitly, meaning the |
callback | Name of the callback function. Used to get a JSONP response. |
POST /api/v1.5/tr.json/translate?lang=en-ru&key=API-KEY HTTP/1.1
Host: translate.yandex.net
Accept: */*
Content-Length: 17
Content-Type: application/x-www-form-urlencoded
text=Hello World!
HTTP/1.1 200 OK
Server: nginx
Content-Type: application/json; charset=utf-8
Content-Length: 68
Connection: keep-alive
Keep-Alive: timeout=120
X-Content-Type-Options: nosniff
Date: Thu, 31 Mar 2016 10:50:20 GMT
{
"code": 200,
"lang": "en-ru",
"text": [
"Здравствуй, Мир!"
]}
XML interface
The response is returned in XML format.
Request syntax
https://translate.yandex.net/api/v1.5/tr/translate
? [key=<API key>]
& [text=<text to translate>]
& [lang=<translation direction>]
& [format=<text format>]
& [options=<translation options>]
key | |
text | The text to be translated. You can use several Attention. For the source text, use the URL encoding. Limitations:
|
lang | Translation direction. Can be set using one of the following methods:
|
format | Text format. Possible values:
|
options | Currently, the only available option is to include the automatically defined source language in the response. This corresponds to the parameter value If the source language is set explicitly, meaning the |
key | |
text | The text to be translated. You can use several Attention. For the source text, use the URL encoding. Limitations:
|
lang | Translation direction. Can be set using one of the following methods:
|
format | Text format. Possible values:
|
options | Currently, the only available option is to include the automatically defined source language in the response. This corresponds to the parameter value If the source language is set explicitly, meaning the |
POST /api/v1.5/tr/translate?lang=en-ru&key=API-KEY HTTP/1.1
Host: translate.yandex.net
Accept: */*
Content-Length: 17
Content-Type: application/x-www-form-urlencoded
text=Hello World!
Response codes
Description of response codes.
Value | Description |
---|---|
200 | The operation was completed successfully |
401 | Invalid API key |
402 | The API key is blocked |
404 | The daily limit on the amount of translated text is exceeded |
413 | The maximum allowed text size is exceeded |
422 | The text can't be translated |
501 | The specified translation direction isn't supported |
Value | Description |
---|---|
200 | The operation was completed successfully |
401 | Invalid API key |
402 | The API key is blocked |
404 | The daily limit on the amount of translated text is exceeded |
413 | The maximum allowed text size is exceeded |
422 | The text can't be translated |
501 | The specified translation direction isn't supported |