Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Intertech Services AG
Yandex Translate
  • Getting started
  • Step-by-step instructions
  • Concepts
  • API reference
    • Authentication in the API
    • gRPC
    • REST
      • v2
      • v1 (DEPRECATED)
        • Overview
        • How to translate text
        • Detecting language
        • List of supported languages
        • Response format
  • Quotas and limits
  • Access management
  • Pricing policy
  • Questions and answers
  1. API reference
  2. REST
  3. v1 (DEPRECATED)
  4. How to translate text

How to translate text

Written by
Yandex Cloud
  • Request
    • Parameters in the request body
  • Response
  • Examples
    • Sample request
    • Response example

Translates the source text into the specified language.

Request

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

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 translate.
You can use multiple text parameters in a request.
source Language of the source text.
Set as a two-letter language code according to ISO-639-1 (for example, en). If this parameter is omitted, the service tries to detect the source language automatically.
target Required parameter.
Translation direction.
Set as a two-letter language code according to ISO-639-1 (for example en).
format Text format.
Possible values:
  • plain: Text without markup (default value)
  • html: Text in HTML format.
folderId Required parameter.
The ID of your folder.

Response

The response is returned in JSON format.

{
    "translations": [
        {"text": <text translation>},
        ...
    ]
}

Examples

Sample request

export FOLDER_ID=<folder id>
export TOKEN=<IAM-token>
curl -X POST \
     -H "Authorization: Bearer ${TOKEN}" \
     -d "folderId=${FOLDER_ID}&target=en" \
     --data-urlencode "text=Hello world" \
     --data-urlencode "text=good morning" \
     "https://translate.api.cloud.yandex.net/translate/v1/translate"

Response example

The response is returned in JSON format.

{
    "translations": [
        {
            "text": "Hello world"
        },
        {
            "text": "good morning"
        }
    ]
}

Was the article helpful?

Language / Region
Yandex project
© 2023 Intertech Services AG
In this article:
  • Request
  • Parameters in the request body
  • Response
  • Examples
  • Sample request
  • Response example