API Translate

API Documentation home

Quick Example

curl -X GET \
     -H 'MMT-ApiKey: <your_api_key>' \
     'https://api.modernmt.com/translate?source=en&target=it&q=Hello=&context=Mr%20President' \
     | python -mjson.tool
{
    "data": {
        "contextVector": {
            "entries": [
                {"memory": {"id": 1, "name": "europarl"}, "score": 0.20658109},
                {"memory": {"id": 2, "name": "ibm"}, "score": 0.0017772929}
            ]
        },
        "translation": "Ciao"
    },
    "status": 200
}

Description

This method returns the translation of the provided text. The text is XML encoded and can contain XML Tags.

Resource URL

https://api.modernmt.com/translate

Parameters

Name Description
source
optional
The language tag of the source language. Auto detection if omitted.

Example: en
target The language tag of the target language.

Example: it
q
The text to translate or an array of texts (XML tags accepted, text must be XML-encoded). The maximum length of the array is 128.

Example: This is an example
context_vector
optional
The context vector to use in the translation, as a series of comma-separated key-value pairs `id1:score1,id2:score2,...`.

Example: 1:0.34,3:0.045
hints
optional
A list containing the Memories to use for this translation.

Example: 10
priority
optional
The priority of the translation request. It can be either normal or background. Default value depends on your plan.

Result

Name Description
translation The translation of the input sentence.
contextVector The Context Vector object calculated by analyzing the context text provided. For more details on the object format, please have a look at API Get Context Vector.
characters The amount of characters of the input text.
billedCharacters Indicates how many chars have been billed to the user.
billed Boolean, true if there's any billed character, false otherwise.
detectedLanguage The detected source language (if source is omitted in request).

Multiple texts example

curl -H "MMT-ApiKey: <your_api_key>" \
     -X POST -H "X-HTTP-Method-Override: GET" \
     -H "Content-Type: application/json" \
     --data '{"target":"it", "q":["This is just a test.", "Dies ist beispieltext"]}' \
     https://api.modernmt.com/translate | python -mjson.tool
{
  "status": 200,
  "data": [
    {
      "translation": "Questo è solo un test.",
      "billedCharacters": 20,
      "characters": 20,
      "detectedLanguage": "en",
      "billed": true
    },
    {
      "translation": "Questo è un testo di esempio",
      "billedCharacters": 21,
      "characters": 21,
      "detectedLanguage": "de",
      "billed": true
    }
  ]
}

Detection Languages

Currently, the following 47 languages are supported.

A
Albanian
Arabic

B
Bosnian
Bulgarian


C
Catalan
Chinese Simplified
Chinese Traditional
Croatian
Czech

D
Danish
Dutch

E
English
Estonian
F
Finnish
French

G
German
Greek

H
Hebrew
Hungarian

I
Icelandic
Indonesian
Italian

J
Japanese

K
Korean
L
Latvian
Lithuanian

M
Macedonian
Malay
Maltese

N
Norwegian Bokmal
Norwegian Nynorsk

P
Polish
Portuguese
Portuguese Brazil

R
Romanian
Russian
S
Serbian Cyrillic
Serbian Latin
Slovak
Slovenian
Spanish
Spanish Latin America
Swedish

T
Thai
Turkish

U
Ukrainian

V
Vietnamese