tencent cloud

文档反馈

TextTranslate

最后更新时间:2024-11-26 11:22:12

    1. API Description

    Domain name for API request: tmt.intl.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
    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), 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), fr (French), es (Spanish), it (Italian), tr (Turkish), ru (Russian), pt (Portuguese), vi (Vietnamese), id (Bahasa Indonesian), th (Thai), and ms (Malay)
  • en (English): zh (Simplified Chinese), zh-TW (Traditional Chinese), ja (Japanese), fr (French), es (Spanish), it (Italian), de (German), tr (Turkish), vi (Vietnamese), id (Bahasa Indonesian), th (Thai), ms (Malay), and hi (Hindi)
  • fr (French): zh (Simplified Chinese), zh-TW (Traditional Chinese) and en (English)
  • it (Italian): zh (Simplified Chinese), zh-TW (Traditional Chinese) and en (English)
  • de (German): zh (Simplified Chinese), zh-TW (Traditional Chinese) and en (English)
  • ru (Russian): zh (Simplified Chinese) and zh-TW (Traditional Chinese)
  • tr (Turkish): zh (Simplified Chinese) and zh-TW (Traditional Chinese)
  • pt (Portuguese): zh (Simplified Chinese) and tr (Turkish)
  • es (Spanish): zh (Simplified Chinese), zh-TW (Traditional Chinese) and en (English)
  • ja (Japanese): zh (Simplified Chinese), zh-TW (Traditional Chinese) and en (English)
  • vi (Vietnamese): zh (Simplified Chinese), zh-TW (Traditional Chinese) and en (English)
  • th (Thai): zh (Simplified Chinese) and en (English)
  • id (Bahasa Indonesian): zh (Simplified Chinese), zh-TW (Traditional Chinese) and en (English)
  • ms (Malay): zh (Simplified Chinese) and zh-TW (Traditional Chinese)
  • ar (Arabic): en (English)
  • hi (Hindi): en (English)
  • ProjectId Yes Integer The project ID, which can be obtained from Console -> 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.
    TermRepoIDList.N No Array of String
    SentRepoIDList.N No Array of String

    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, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 TextTranslate Example

    TextTranslate from English to Chinese

    Input Example

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

    Output Example

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

    5. Developer Resources

    SDK

    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.ErrorUserArea
    FailedOperation.LanguageRecognitionErr
    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.RequestAiLabErr
    FailedOperation.ServiceIsolate The service is suspended due to overdue payments. Top up your account first.
    FailedOperation.StopUsing
    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.ErrorGetRoute
    InternalError.ErrorUnknown Unknown error.
    InternalError.RequestFailed Request failed.
    InvalidParameter Invalid parameter.
    InvalidParameter.MissingParameter Invalid parameter.
    InvalidParameterValue
    LimitExceeded The quota limit is reached.
    LimitExceeded.LimitedAccessFrequency The request frequency limit is reached.
    MissingParameter Missing parameter.
    RequestLimitExceeded.UinLimitExceeded
    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.