Detecting language
Written by
Updated at January 18, 2024
Warning
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. Learn more about how to find out the folder ID. |
Response
The response is returned in JSON format.
{
"language": <language_code>
}
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=hello world" \
"https://translate.api.cloud.yandex.net/translate/v1/detect"
Response example
The response is returned in JSON format.
{
"language": "en"
}