translate method

Translates the text.


Translation translate(string key, string lang, string text[], string format, string options);

Input parameters

Input parameters can be passed either using an HTTP GET request (see the example), or using an HTTP POST request where the parameters are passed in the body of the HTTP request.

Sample request:

XML interface:,+or+not+to+be%3F&text=That+is+the+question.

JSON interface:,+or+not+to+be%3F&text=That+is+the+question.

JSONP interface (for the "myCallback" function):,+or+not+to+be%3F&text=That+is+the+question.&callback=myCallback

List of input parameters.

key string API key. Get a free API key on this page.
lang string

Translation direction (for example, "en-ru" or "ru"). Format:

  1. A pair of language codes separated by a dash. For example, "en-ru" specifies to translate from English to Russian.
  2. Single language code. For example, "ru" specifies to translate to Russian. In this case, the language of the original text is detected automatically.
text string[]

The text to be translated.


  • 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.
format string

Text format.

Possible values:

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

Translation options.

Possible values:

  • 1 - Automatically detect language. For example, if the lang parameter has reversed the translation direction for a pair, the service automatically detects the text language and returns it in the detected tag:привет&options=1
    <Translation code="200" lang="en-ru">
      <detected lang="ru"/>


In the XML interface, it returns the Translation structure, which contains the translated text. For example:

<?xml version="1.0" encoding="utf-8"?>
<Translation code="200" lang="en-ru">
   <text>Быть или не быть?</text>
   <text>Вот в чем вопрос.</text>

Elements of the response XML schema:

  • Translation — The root element, which contains text elements (one per fragment). The code attribute contains the return code (see the table) and the lang attribute, which is the language code of the text fragment detected by the service.
  • text — An array of strings with translated text (for the XML interface, a sequence of <text> elements). The number of items in the array corresponds to the number of text parameters in the request.

Table 1. Error codes

ERR_OK 200

Operation completed successfully.


Invalid API key.


This API key has been blocked.


You have reached the daily limit for requests (including calls of the detect method).


You have reached the daily limit for the volume of translated text (including calls of the detect method).


The text size exceeds the maximum.


The text could not be translated.


The specified translation direction is not supported.

In the JSON interface, instead of XML elements, JavaScript objects are returned with the same names and semantics:

   "code": 200,
   "lang": "en-ru",
   "text": [
      "Быть или не быть?",
      "Вот в чем вопрос."

In the JSONP interface, the same JavaScript objects are returned to a callback function (for example, "myCallback"):

   "code": 200,
   "lang": "en-ru",
   "text": [
      "Быть или не быть?",
      "Вот в чем вопрос."