Documentation

Detect the language

Detects the language of the specified text.

In this section:

The response is returned as the language code. To define the language name by its code, use the Get the list of supported languages operation and set the ui parameter when calling.

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 the name specified in this parameter (JSONP).

Request syntax

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

API key. It is issued free of charge.

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

The text to detect the language for.

Attention! The source text must be URL-encoded.
]no-highlight]
=<text> & [hint
[no-highlight[

A list of the most likely languages (they will be given preference when detecting the text language). Use the comma as a separator.

]no-highlight]
=<list of probable text languages>] & [callback
[no-highlight[The name of the callback function. Use for getting a JSONP response.]no-highlight]
=<name of the callback function>]
key

API key. It is issued free of charge.

text

The text to detect the language for.

Attention! The source text must be URL-encoded.
hint

A list of the most likely languages (they will be given preference when detecting the text language). Use the comma as a separator.

callbackThe name of the callback function. Use for getting a JSONP response.
Note. All special characters must be escaped.
POST /api/v1.5/tr.json/detect?hint=en,de&key=API-KEY HTTP/1.1
Host: translate.yandex.net
Accept: */*
Content-Length: 17
Content-Type: application/x-www-form-urlencoded

text=Hello World!
{
    "code": 200,
    "lang": "en"
}

XML interface

The response is returned in XML format.

Request syntax

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

API key. It is issued free of charge.

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

The text to detect the language for.

Attention! The source text must be URL-encoded.
]no-highlight]
=<text> & hint
[no-highlight[

A list of the most likely languages (they will be given preference when detecting the text language). Use the comma as a separator.

]no-highlight]
=<list of probable text languages>
key

API key. It is issued free of charge.

text

The text to detect the language for.

Attention! The source text must be URL-encoded.
hint

A list of the most likely languages (they will be given preference when detecting the text language). Use the comma as a separator.

Note. All special characters must be escaped.
POST /api/v1.5/tr/detect?hint=en,de&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/xml; 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

<?xml version="1.0" encoding="utf-8"?>
<DetectedLang code="200" lang="en"/>

Response codes

Explanations of possible response codes.
ValueDescription
200

Operation completed successfully

401

Invalid API key

402

Blocked API key

404

Exceeded the daily limit on the amount of translated text