Detecting language
Written by
Updated at November 2, 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.
When using the Translate API, provide your authentication credentials in the Authorization
header of each request.
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 |
This is a required parameter. UTF-8 encoded text for language detection. |
hint |
List of most probable languages (they will be given priority when detecting the language). The list items are comma-separated. |
folderId |
This is a required parameter. Your folder ID. Learn more about how to get a folder ID. |
Response
The response is returned in JSON format.
{
"language": <language_code>
}
Examples
Request example
export FOLDER_ID=<folder_ID>
export TOKEN=<IAM_token>
curl \
--request POST \
--header "Authorization: Bearer ${TOKEN}" \
--data "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"
}