Getting a list of supported languages
Getting started
To use the examples, install cURL
To authenticate under a service account, you can use an API key or an IAM token; to authenticate under a user account, you can only use an IAM token.
Get your account details for authentication in the Translate API:
-
If you do not have a service account, create one.
-
Assign the
ai.translate.userrole for the folder to the service account. -
Get the ID of the folder your service account was created in. Make sure to include the folder ID in the
folderIdfield in the body of each request. -
Create an API key with the
yc.ai.translate.executescope.Provide the key in the
Authorizationheader of each request in the following format:Authorization: Api-Key <API_key>
-
Get the ID of any folder for which your account has the
ai.translate.userrole or higher. Make sure to include the folder ID in thefolderIdfield in the body of each request. -
Get an IAM token for your Yandex account, federated account, local account, or service account.
Provide the token in the
Authorizationheader of each request in the following format:Authorization: Bearer <IAM_token>
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 API_KEY=<API_key>
curl \
--request POST \
--header "Content-Type: application/json" \
--header "Authorization: Api-Key ${API_KEY}" \
--data "{\"folderId\": \"${FOLDER_ID}\"}" \
"https://translate.api.cloud.yandex.net/translate/v2/languages"
Where:
FOLDER_ID: Folder ID you got before you started.-
Where
API_KEYis the API key you got before you started. If you use an IAM token for authentication, change theAuthorizationheader to"Authorization: Bearer <IAM_token>".
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"
},
...
]
}