Documentation

Translating a text

Translates text to the specified language.

Interfaces:

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 with a name corresponding to the value of this parameter (JSONP).

Request syntax

https://translate.yandex.net/api/v1.5/tr.json/translate ? 
key
[no-highlight[

API key. It is issued free of charge.

]no-highlight]
=<API key> & text
[no-highlight[

The text to translate.

You can use multiple text parameters in a request.

Restrictions:

  • For POST requests, the maximum size of the text being passed is 10000 characters.
  • In GET requests, the restriction applies not to the text itself, but to the size of the entire request string, which can contain other parameters besides the text.

    The maximum size of the request string is 10 kB.

]no-highlight]
=<text to translate> & lang
[no-highlight[

The translation direction.

You can use any of the following ways to set it:

  • As a pair of language codes separated by a hyphen (“from”-“to”). For example, en-ru indicates translating from English to Russian.
  • As the final language code (for example, ru). In this case, the service tries to detect the source language automatically.
]no-highlight]
=<translation direction> & [format
[no-highlight[

Text format.

Possible values:

  • plain - Text without markup (default value).
  • html - Text in HTML format.
]no-highlight]
=<text format>] & [options
[no-highlight[

The only option available at this time is whether the response should include the automatically detected language of the text being translated. This corresponds to the value 1 for this parameter.

If the language of the text being translated is defined explicitly, meaning the lang parameter is set as a pair of codes, the first code defines the source language. This means that the options parameter does not allow switching to automatic language detection. However, it does allow you to understand whether the source language was defined correctly in the lang parameter.

]no-highlight]
=<translation options>] & [callback
[no-highlight[The name of the callback function. Used when a JSONP response is desired.]no-highlight]
=<name of the callback function>]
key

API key. It is issued free of charge.

text

The text to translate.

You can use multiple text parameters in a request.

Restrictions:

  • For POST requests, the maximum size of the text being passed is 10000 characters.
  • In GET requests, the restriction applies not to the text itself, but to the size of the entire request string, which can contain other parameters besides the text.

    The maximum size of the request string is 10 kB.

lang

The translation direction.

You can use any of the following ways to set it:

  • As a pair of language codes separated by a hyphen (“from”-“to”). For example, en-ru indicates translating from English to Russian.
  • As the final language code (for example, ru). In this case, the service tries to detect the source language automatically.
format

Text format.

Possible values:

  • plain - Text without markup (default value).
  • html - Text in HTML format.
options

The only option available at this time is whether the response should include the automatically detected language of the text being translated. This corresponds to the value 1 for this parameter.

If the language of the text being translated is defined explicitly, meaning the lang parameter is set as a pair of codes, the first code defines the source language. This means that the options parameter does not allow switching to automatic language detection. However, it does allow you to understand whether the source language was defined correctly in the lang parameter.

callbackThe name of the callback function. Used when a JSONP response is desired.

XML interface

The response is returned in XML format.

Request syntax

https://translate.yandex.net/api/v1.5/tr/translate ? 
key
[no-highlight[

API key. It is issued free of charge.

]no-highlight]
=<API key> & text
[no-highlight[

The text to translate.

You can use multiple text parameters in a request.

Restrictions:

  • For POST requests, the maximum size of the text being passed is 10000 characters.
  • In GET requests, the restriction applies not to the text itself, but to the size of the entire request string, which can contain other parameters besides the text.

    The maximum size of the request string is 10 kB.

]no-highlight]
=<text to translate> & lang
[no-highlight[

The translation direction.

You can use any of the following ways to set it:

  • As a pair of language codes separated by a hyphen (“from”-“to”). For example, en-ru indicates translating from English to Russian.
  • As the final language code (for example, ru). In this case, the service tries to detect the source language automatically.
]no-highlight]
=<translation direction> & [format
[no-highlight[

Text format.

Possible values:

  • plain - Text without markup (default value).
  • html - Text in HTML format.
]no-highlight]
=<text format>] & [options
[no-highlight[

The only option available at this time is whether the response should include the automatically detected language of the text being translated. This corresponds to the value 1 for this parameter.

If the language of the text being translated is defined explicitly, meaning the lang parameter is set as a pair of codes, the first code defines the source language. This means that the options parameter does not allow switching to automatic language detection. However, it does allow you to understand whether the source language was defined correctly in the lang parameter.

]no-highlight]
=<translation options>]
key

API key. It is issued free of charge.

text

The text to translate.

You can use multiple text parameters in a request.

Restrictions:

  • For POST requests, the maximum size of the text being passed is 10000 characters.
  • In GET requests, the restriction applies not to the text itself, but to the size of the entire request string, which can contain other parameters besides the text.

    The maximum size of the request string is 10 kB.

lang

The translation direction.

You can use any of the following ways to set it:

  • As a pair of language codes separated by a hyphen (“from”-“to”). For example, en-ru indicates translating from English to Russian.
  • As the final language code (for example, ru). In this case, the service tries to detect the source language automatically.
format

Text format.

Possible values:

  • plain - Text without markup (default value).
  • html - Text in HTML format.
options

The only option available at this time is whether the response should include the automatically detected language of the text being translated. This corresponds to the value 1 for this parameter.

If the language of the text being translated is defined explicitly, meaning the lang parameter is set as a pair of codes, the first code defines the source language. This means that the options parameter does not allow switching to automatic language detection. However, it does allow you to understand whether the source language was defined correctly in the lang parameter.

Response codes

ValueDescription
200

Operation completed successfully

401

Invalid API key

402

Blocked API key

403

Exceeded the daily limit on the number of requests

404

Exceeded the daily limit on the amount of translated text

413

Exceeded the maximum text size

422

The text cannot be translated

501

The specified translation direction is not supported