tencent cloud



Last updated: 2022-11-18 11:53:52

    1. API Description

    Domain name for API request: tmt.tencentcloudapi.com.

    This API is used to translate text in multiple language pairs, such as Chinese-English.

    Note: We recommend that you simplify your development with the SDK integration mode. For how to use the SDK, see Section 5 "Developer Resources".

    A maximum of 5 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: TextTranslate.
    Version Yes String Common Params. The value used for this API: 2018-03-21.
    Region Yes String Common Params. For more information, please see the list of regions supported by the product.
    SourceText Yes String The texts to be translated, which must be encoded in UTF-8 and can contain up to 2,000 characters in a request. For non-pure texts such as those with HTML tags, the translation may fail.
    Source Yes String Supported source languages:
    auto: Automatic language detection
    zh: Simplified Chinese
    zh_TW: Traditional Chinese
    en: English
    ja: Japanese
    ko: Korean
    fr: French
    es: Spanish
    it: Italian
    de: German
    tr: Turkish
    ru: Russian
    pt: Portuguese
    vi: Vietnamese
    id: Bahasa Indonesian
    th: Thai
    ms: Malay
    ar: Arabic
    hi: Hindi
    Target Yes String Supported target languages for the above source languages:

  • zh (Simplified Chinese): en (English), ja (Japanese), ko (Korean), fr (French), es (Spanish), it (Italian), de (German), tr (Turkish), ru (Russian), pt (Portuguese), vi (Vietnamese), id (Bahasa Indonesian), th (Thai), and ms (Malay)
  • zh-TW (Traditional Chinese): en (English), ja (Japanese), ko (Korean), fr (French), es (Spanish), it (Italian), de (German), tr (Turkish), ru (Russian), pt (Portuguese), vi (Vietnamese), id (Bahasa Indonesian), th (Thai), and ms (Malay)
  • en (English): zh (Simplified Chinese), ja (Japanese), ko (Korean), fr (French), es (Spanish), it (Italian), de (German), tr (Turkish), ru (Russian), pt (Portuguese), vi (Vietnamese), id (Bahasa Indonesian), th (Thai), ms (Malay), ar (Arabic), and hi (Hindi)
  • ja (Japanese): zh (Simplified Chinese), en (English), and ko (Korean)
  • ko (Korean): zh (Simplified Chinese), en (English), and ja (Japanese)
  • fr (French): zh (Simplified Chinese), en (English), es (Spanish), it (Italian), de (German), tr (Turkish), ru (Russian), and pt (Portuguese)
  • es (Spanish): zh (Simplified Chinese), en (English), fr (French), it (Italian), de (German), tr (Turkish), ru (Russian), and pt (Portuguese)
  • it (Italian): zh (Simplified Chinese), en (English), fr (French), es (Spanish), de (German), tr (Turkish), ru (Russian), and pt (Portuguese)
  • de (German): zh (Simplified Chinese), en (English), fr (French), es (Spanish), it (Italian), tr (Turkish), ru (Russian), and pt (Portuguese)
  • tr (Turkish): zh (Simplified Chinese), en (English), fr (French), es (Spanish), it (Italian), de (German), ru (Russian), and pt (Portuguese)
  • ru (Russian): zh (Simplified Chinese), en (English), fr (French), es (Spanish), it (Italian), de (German), tr (Turkish), and pt (Portuguese)
  • pt (Portuguese): zh (Simplified Chinese), en (English), fr (French), es (Spanish), it (Italian), de (German), tr (Turkish), and ru (Russian)
  • vi (Vietnamese): zh (Simplified Chinese) and en (English)
  • id (Bahasa Indonesian): zh (Simplified Chinese) and en (English)
  • th (Thai): zh (Simplified Chinese) and en (English)
  • ms (Malay): zh (Simplified Chinese) and en (English)
  • ar (Arabic): en (English)
  • hi (Hindi): en (English)
  • Account Center -> Project Management**. If no one is set, enter the default project ID 0.
    UntranslatedText No String The parameter used to mark the text content that needs to remain untranslated, such as special symbols and names of people and places. You can set only one word for this parameter in each request. Only nouns (like names of people and places) are supported, and verbs or phrases may cause poor translation outcomes.

    3. Output Parameters

    Parameter Name Type Description
    TargetText String The translation outcome.
    Source String The source language. See the request parameter Source for details.
    Target String The target language. See the request parameter Target for details.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Calling the API

    Input Example

    POST / HTTP/1.1
    Host: tmt.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: TextTranslate
    <Common request parameters>
      "SourceText": "hello",
      "ProjectId": "0",
      "Target": "zh",
      "Source": "en"

    Output Example

      "Response": {
          "TargetText": "hello",
          "Source": "en",
          "Target": "zh",
          "RequestId": "000ee211-f19e-4a34-a214-e2bb1122d248"

    5. Developer Resources


    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation.NoFreeAmount The free quota for this month is used up. To continue to use the service, you need to upgrade to a paid account in the TMT console.
    FailedOperation.ServiceIsolate The service is suspended due to overdue payments. Top up your account first.
    FailedOperation.UserNotRegistered The service is not activated. Activate it in the TMT console first.
    InternalError Internal error.
    InternalError.BackendTimeout Backend service timeout. Please try again later.
    InternalError.ErrorUnknown Unknown error.
    InternalError.RequestFailed Request failed.
    InvalidParameter Invalid parameter.
    InvalidParameter.MissingParameter Invalid parameter.
    LimitExceeded The quota limit is reached.
    LimitExceeded.LimitedAccessFrequency The request frequency limit is reached.
    MissingParameter Missing parameter.
    UnauthorizedOperation.ActionNotFound Incorrect name entered in the Action field.
    UnsupportedOperation Unsupported operation.
    UnsupportedOperation.TextTooLong The text length limit (2,000 characters) for a request is reached.
    UnsupportedOperation.UnSupportedTargetLanguage Unsupported target language. Please refer to the supported language list.
    UnsupportedOperation.UnsupportedLanguage Unsupported language. Please refer to the supported language list.
    UnsupportedOperation.UnsupportedSourceLanguage Unsupported source language. Please refer to the supported language list.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support