Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
Yandex Translate
  • Getting started
  • Step-by-step instructions
    • All instructions
    • How to translate text
    • How to improve the accuracy of translations
    • Detecting language
    • Getting a list of supported languages
  • Concepts
    • Overview
    • Retraining models
    • Supported languages
    • Glossaries
    • Glossary support
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • TranslationService
    • REST
      • v2
        • Handling errors
        • Troubleshooting
        • Overview
        • Translation
          • Overview
          • detectLanguage
          • listLanguages
          • translate
      • v1 (DEPRECATED)
        • Overview
        • How to translate text
        • Detecting language
        • List of supported languages
        • Response format
  • Quotas and limits
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Policy before January 1, 2019
  • 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

Warning

Support for v1 is discontinued as of February 2019. The methods listed below will be deprecated. Please use v2.

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, ru). 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=привет мир" \
     --data-urlencode "text=доброе утро" \
     "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 Yandex.Cloud LLC
In this article:
  • Request
  • Parameters in the request body
  • Response
  • Examples
  • Sample request
  • Response example