Determining language
Determines the language the given text is written in.
Overview
The response is returned as a language code. You can determine the language name by its code using the Getting the list of supported languages operation with the the ui parameter.
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/detect
? [key=<API-key>]
& text=<text>
& [hint=<list of likely text languages>]
& [callback=<callback-function name>]
|
|
|
The text whose language you want to define. Warning For the source text, use the URL encoding. |
|
List of the most likely languages (they will be given preference when determining the text language). The list is separated with commas. |
|
Name of the callback function. Used to get a JSONP response. |
* Required
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=<API-key>]
& text=<text>
& [hint=<list of likely text languages>]
|
|
|
The text whose language you want to define. Warning For the source text, use the URL encoding. |
|
List of the most likely languages (they will be given preference when determining the text language). The list is separated with commas. |
* Required
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
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 |
The text whose language you want to define.
Warning
For the source text, use the URL encoding.
List of the most likely languages (they will be given preference when determining the text language). The list is separated with commas.
Name of the callback function. Used to get a JSONP response.
Required
Required parameter. In the response, the list of supported languages can be found in the langs field together with an explanation of language codes. Language names are output in the language whose code corresponds to this parameter. All language codes are listed in the list of supported languages.