Getting a list of supported languages
Getting started
To use the examples, install cURL
The Translate API requires you to send your authentication credentials in each request. The authentication method depends on the type of account used to send your request:
-
Get an IAM token to authenticate your Yandex account or federated account. Transmit the token in the
Authorization
header of each request in the following format:Authorization: Bearer <IAM token>
-
Get the ID of any folder for which your account has the
ai.translate.user
role or higher. Make sure to include your folder ID in thefolderId
field in the body of each request.
-
Choose one of the authentication methods:
-
Get an IAM token. Include the IAM token in the
Authorization
header in the following format:Authorization: Bearer <IAM token>
-
Create an API key. Include the API key in the
Authorization
header in the following format:Authorization: Api-Key <API key>
-
-
Assign the service account the
ai.translate.user
role or higher for the folder where it was created.Do not specify the folder ID in your requests, as YandexGPT uses the folder in which the service account was created.
The example below is intended to be run in MacOS and Linux. To run it in Windows, see how to work with Bash in Microsoft Windows.
Get the list of supported languages
Get the list of supported languages using the listLanguages method:
export FOLDER_ID=<folder_ID>
export IAM_TOKEN=<IAM_token>
curl \
--request POST \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${IAM_TOKEN}" \
--data "{\"folderId\": \"${FOLDER_ID}\"}" \
"https://translate.api.cloud.yandex.net/translate/v2/languages"
Where:
FOLDER_ID
: Folder ID you got before you started.IAM_TOKEN
: IAM token you got before you started.
The response will contain a list of language names in the corresponding language:
{
"languages": [
{
"code": "az",
"name": "azərbaycan"
},
{
"code": "sq",
"name": "shqip"
},
{
"code": "am",
"name": "አማርኛ"
},
{
"code": "en",
"name": "English"
},
...
]
}