Language detection

Important

Support for v1 is discontinued as of February 2019. The methods listed below will be deprecated. Please use v2.

Detects the language of the source text. The response is returned as the language code.

Request

POST https://translate.api.cloud.yandex.net/translate/v1/detect

Parameters in the request body

All parameters must be URL-encoded. The maximum size of the POST request body is 30 KB.

Parameter Description
text Required parameter.
UTF-8 encoded text to detect the language of.
hint List of most probable languages (they will be given priority when detecting the language). The list items are comma-separated.
folderId Required parameter.
ID of your folder.
For more information about how to find out the folder ID, see the section Authorization in the API.

Response

The response is returned in JSON format.

{
    "language": <code of the language the text is in>
}

Examples

Sample request

export FOLDER_ID=<folder id>
export TOKEN=<IAM-token>
curl -X POST \
     -H "Authorization: Bearer ${TOKEN}" \
     -d "folderId=${FOLDER_ID}" \
     --data-urlencode "text=привет мир" \
     "https://translate.api.cloud.yandex.net/translate/v1/detect"

Response example

The response is returned in JSON format.

{
    "language": "ru"
}