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 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>]
key | |
text * | The text whose language you want to define. Attention. For the source text, use the URL encoding. |
hint | List of the most likely languages (they will be given preference when determining the text language). The list is separated with commas. |
callback | Name of the callback function. Used to get a JSONP response. |
key | |
text * | The text whose language you want to define. Attention. For the source text, use the URL encoding. |
hint | List of the most likely languages (they will be given preference when determining the text language). The list is separated with commas. |
callback | Name of the callback function. Used to get a JSONP response. |
* Required
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>]
key | |
text * | The text whose language you want to define. Attention. For the source text, use the URL encoding. |
hint | List of the most likely languages (they will be given preference when determining the text language). The list is separated with commas. |
* Required
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
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 |
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 |