Google

  1. Home
  2. Add-on
  3. Translation Proxy
  4. Unified API
  5. Google

Google

Path

https://localhost:8877/translate_a/single

Parameters

To use this API, you need to send a POST or GET request with the following parameters:

  • client: The client type. You can use gtx for the web version or dict-chrome-ex for the Chrome extension version.
  • sl: The source language code. You can use auto to detect the language automatically or specify a language code such as en for English or ja for Japanese.
  • tl: The target language code. You need to specify a language code such as fr for French or zh-CN for Simplified Chinese.
  • dt: The data type. You can use one or more of the following values separated by commas:
    • t: Translated text
    • at: Alternative translations
    • rm: Transliteration
    • bd: Dictionary definitions
    • md: Metadata
    • ss: Synonyms
    • ex: Examples
    • rw: Related words
  • q: The query text. You can use one or more texts separated by newlines.

Example

For example, if you want to translate “Hello” and “How are you?” from English to French and get the translated text, alternative translations, and transliteration, you can send a POST request like this:

POST https://localhost:8877/translate_a/single?client=gtx&sl=en&tl=fr&dt=t,at,rm&q=Hello%0AHow%20are%20you%3F

The response will be a JSON array like this:

[
  [
    [
      "Bonjour",
      "Hello",
      null,
      null,
      1
    ],
    [
      "Comment allez-vous?",
      "How are you?",
      null,
      null,
      1
    ]
  ],
  [
    [
      "Salut",
      null,
      1,
      [
        [
          "Hi",
          1000,
          true,
          false
        ],
        [
          "Hey",
          1000,
          true,
          false
        ]
      ]
    ],
    [
      "Comment ça va?",
      null,
      1,
      [
        [
          "How are you doing?",
          1000,
          true,
          false
        ],
        [
          "How is it going?",
          1000,
          true,
          false
        ]
      ]
    ]
  ],
  [
    [
      "bohn-zhoor",
      "Hello"
    ],
    [
      "koh-mahn tahl-ay voo",
      "How are you?"
    ]
  ],
  null,
  "en",
  null,
  null,
  null,
  null,
  null,
  null,
  null
]

The first element of the array is the translated text, the second element is the alternative translations, and the third element is the transliteration. The other elements are null or metadata.

Was this article helpful to you? No Yes

How can we help?