Tuesday, December 5, 2017

Google Translate Query Parameters

  • HTTP request

    POST https://translation.googleapis.com/language/translate/v2

    • sl - source language code (auto for autodetection)tl - translation language
    • q - source text / word
    • ie - input encoding (a guess)
    • oe - output encoding (a guess)
    • dt - may be included more than once and specifies what to return in the reply.
Here are some values for dt. If the value is set, the following data will be returned:
  • t - translation of source text
  • at - alternate translations
  • rm - transcription / transliteration of source and translated texts
  • bd - dictionary, in case source text is one word (you get translations with articles, reverse translations, etc.)
  • md - definitions of source text, if it's one word
  • ss - synonyms of source text, if it's one word
  • ex - examples
  • rw - See also list.
  • client t probably represents the standalone google translate web app (as opposed to a mobile app, or the widget that pops up if you google search "translate")
  • sl is source language
  • tl is translate language (the language you want to translate into)
  • srcrom seems to be present when the source text has no spelling suggestions
sl:auto
tl:sk
hl:sk //language of the interface (default:en, you can try xx-bork or xx-hacker)
dt:ld - ?
dt:qc - ?
dt:rm - ?
dt:ss - ?
dt:sw - ?
ie:UTF-8 // encoding of the input (default: utf-8)
oe:UTF-8 // encoding of the output, the results (default: utf-8)
otf:1 - ?
srcrom:1 - ?
ssel:3 - ?
tsel:0 - ?
https://translate.google.com/translate_a/single?client=t&sl=en&tl=it&hl=en&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=1&ssel=0&tsel=0&kc=1&tk=685310.807246&q=c
q string
Required The input text to translate. Repeat this parameter to perform translation operations on multiple text inputs.
target string
Required The language to use for translation of the input text, set to one of the language codes listed in Language Support.
format string
The format of the source text, in either HTML (default) or plain-text. A value of html indicates HTML and a value of text indicates plain-text.
source string
The language of the source text, set to one of the language codes listed in Language Support. If the source language is not specified, the API will attempt to detect the source language automatically and return it within the response.
model string
The translation model. Can be either base to use the Phrase-Based Machine Translation (PBMT) model, or nmt to use the Neural Machine Translation (NMT) model. If omitted, then nmt is used.
If the model is nmt, and the requested language translation pair is not supported for the NMT model, then the request is translated using the base model.

string
key A valid API key to handle requests for this API. If you are using OAuth 2.0 service account credentials (recommended), do not supply this parameter.
Yandex does not provides alignment information either, but unofficially it does, even in the paid service.If you send "options=4" in the query string of the url it returns alignment information.