MachineTranslation.comBy Tomedes  ·  Docs
API Documentation

MachineTranslation.com API Documentation

The MachineTranslation.com API translates text and structured JSON files, and lets you steer the output with a custom instruction and a glossary.

It supports:

  • Plain text translation via JSON requests, with an optional custom instruction
  • Structured JSON file translation, where keys and structure are preserved and only string values are translated. This endpoint also accepts a custom instruction and a glossary (reference file)
✨custom_instruction is available on both endpoints. reference_file is available on the JSON file endpoint only. See Custom Instructions & Glossaries below.

Base URLs

Text translation:

https://api.machinetranslation.com/pv1/translate

JSON file translation:

https://api.machinetranslation.com/pv1/translate/file

Authentication

The API uses BEARER authentication. Include your API key in the Authorization header of every request.

Example

Authorization: BEARER <your_api_key>

Request an API Key

To get an API key, contact us →

Endpoints

1

Create Translation (Text)

POST /pv1/translate translates plain text from one language to another. It supports a custom instruction but not a glossary. The body must be valid JSON.

⚠️Unknown keys, including reference_file, are silently ignored. A multipart upload to this endpoint returns 422 because the body is not valid JSON.

HTTP Request

POST
https://api.machinetranslation.com/pv1/translate

Headers

Authorization: BEARER <your_api_key>
Content-Type: application/json

Request Body

{
  "text": "The text you want to translate",
  "source_language_code": "en",
  "target_language_code": "fr",
  "custom_instruction": "Optional instruction for the translation"
}
FieldTypeRequiredDescription
textstringYesText to be translated
source_language_codestringYesSource language code (e.g. en)
target_language_codestringYesTarget language code (e.g. fr)
custom_instructionstringNoExtra instruction added to the translation prompt. Max 2,000 characters, counted after leading and trailing spaces are trimmed.

Example Request

curl --location 'https://api.machinetranslation.com/pv1/translate' \
  --header 'Authorization: BEARER <your_api_key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "text": "MachineTranslation.com {smart} translates, compares, and recommends the best translations.",
    "source_language_code": "en",
    "target_language_code": "fr",
    "custom_instruction": "Do not translate text inside {curly_braces}; keep placeholders exactly as written."
  }'

Response Example

{
  "translations": [
    {
      "engine": "smart",
      "share_id": "cf733e14-ea86-4f6b-92fc-de9813197601",
      "source_text": "MachineTranslation.com {smart} translates, compares, and recommends the best translations.",
      "target_text": "MachineTranslation.com {smart} traduit, compare et recommande les meilleures traductions.",
      "source_word_count": 9,
      "target_word_count": 9,
      "source_language_code": "en",
      "target_language_code": "fr"
    }
  ]
}

Response Fields

  • translations: Array of results from different engines
  • engine: Translation engine used
  • share_id: Unique ID for the translation
  • source_text / target_text: Original and translated text
  • source_word_count / target_word_count: Word counts
  • source_language_code / target_language_code: Language codes
2

Translate JSON File

POST /pv1/translate/file translates a .json file while preserving its original structure. It accepts .json files only. Any other file type, including DOCX and XLSX, is rejected with 400 Only JSON files allowed before the glossary is read. This endpoint supports both a custom instruction and a glossary.

  • JSON keys and structure are preserved
  • Only string values are translated
  • Numbers, booleans, arrays, and objects remain unchanged

HTTP Request

POST
https://api.machinetranslation.com/pv1/translate/file

Headers

Authorization: BEARER <your_api_key>
Content-Type: multipart/form-data
💡Most HTTP clients automatically handle multipart boundaries.

Request Body (form-data)

FieldTypeRequiredDescription
filefileYesJSON file to translate
source_language_codestringYesSource language code (e.g. en)
target_language_codestringYesTarget language code (e.g. fr)
custom_instructionstringNoExtra instruction added to the translation prompt. Max 2,000 characters, counted after leading and trailing spaces are trimmed.
reference_filefileNoGlossary file whose terms are added to the translation prompt. Max 5 MB and 20,000 characters of text. Supported formats: .txt, .csv, .docx, .xlsx, .xliff, .xml. See Custom Instructions & Glossaries for the file structure.

Example Request

curl --location 'https://api.machinetranslation.com/pv1/translate/file' \
  --header 'Authorization: BEARER <your_api_key>' \
  --form 'source_language_code="en"' \
  --form 'target_language_code="it"' \
  --form 'file=@"/path/to/sample.json"' \
  --form 'custom_instruction="Do not translate text inside {curly_braces}; keep placeholders exactly as written."' \
  --form 'reference_file=@"/path/to/glossary.txt"'

Response Example

{
  "translated_json": {
    "title": "Testo tradotto",
    "description": "La struttura JSON originale viene mantenuta"
  },
  "source_language_code": "en",
  "target_language_code": "it"
}

Notes

  • The response returns a translated_json object with the same structure as the uploaded file.

Custom Instructions & Glossaries

Use these optional parameters to control tone, protect placeholders, or enforce preferred terminology. Both are added to the prompt when the text is translated.

Custom instructionGlossary
Parametercustom_instructionreference_file
Text endpointSupportedNot supported
JSON file endpointSupportedSupported
Sent asStringFile upload (form-data)

How it works

  • Both are optional.
  • Send them with every request. Nothing is saved to your account or API key, so a later call without them is translated without them.
  • Use custom_instruction for rules in plain language, for example: Do not translate text inside {curly_braces}; keep placeholders exactly as written.
  • Use reference_file to supply approved terminology, such as product names and key terms.

Supported glossary file formats

.txt, .csv, .docx, .xlsx, .xliff, .xml

Not accepted: .tsv, .tmx, .tbx, .xls, .doc.

Glossary file structure

FormatStructure
.txt, .csv, .docxOne term per line, written as source = target. A .csv file is not split on commas, and tab-separated lines are not recognised as pairs.
.xlsxSource term in column A and target term in column B, on the first sheet, with no header row.
.xliffStandard <source> / <target> pairs.
.xmlAccepted. The expected element structure is not yet specified.

Example glossary.txt (English to Italian)

SMART Translation = Traduzione SMART
consensus = consenso

.txt and .csv files must be UTF-8. Invalid bytes do not cause an error; they are converted to the � character.

Good to know

  • The glossary goes into the prompt as reference material and the AI model applies it. Matching is best-effort: plurals and inflected forms are usually handled, but there is no guarantee that a term is used exactly as written.
  • A glossary can contain more than one language, but it is not filtered to the request's language pair. The whole file is sent to the engines and the model decides which entries apply. One language pair per file is recommended.
  • The instruction and the glossary are sent to every engine in the consensus. No priority is defined between them, since both go into one prompt block, so avoid instructions that contradict your glossary.
  • The glossary is read in memory, used for that one request, and not stored.
  • The extra prompt tokens from the instruction and glossary do not count toward your usage or credits.

Limits & Errors

Exceeding any limit always returns an error. Input is never silently truncated.

Limits

ParameterLimitApprox. size
custom_instruction2,000 characters, counted after leading and trailing spaces are trimmedAbout 500 English tokens
reference_file size5 MB
reference_file text20,000 characters of text read from the fileAbout 5,000 English tokens
Terms, or characters per termNo separate limit, only the 20,000-character total

Error responses

Exact status codes and messages are published only where they are confirmed. The remaining cases still return an error.

CaseHTTP statusError message
custom_instruction over 2,000 charactersNot yet publishedNot yet published
reference_file over 5 MBNot yet publishedNot yet published
reference_file over 20,000 characters of textNot yet publishedNot yet published
Unsupported reference_file format (for example .tsv or .xls)Not yet publishedNot yet published
Non-.json file sent to /pv1/translate/file400Only JSON files allowed
Multipart upload sent to /pv1/translate422Body is not valid JSON. The exact message text is not yet published.
reference_file or any unknown key in the JSON body of /pv1/translateNo errorSilently ignored
Missing or invalid API keyNot yet publishedNot yet published

Supported Languages

The API supports 332 languages. Use the codes below, for example English en, French fr, Chinese (Simplified) zh, Chinese (Traditional) zh-TW, Spanish es, Portuguese (Brazil) pt, Japanese ja, Arabic ar, and Hindi hi.

Abkhazab
Acehneseace
Acholiach
Aluralz
Afrikaansaf
Albaniansq
Amharicam
Arabicar
Armenianhy
Assameseas
Asturianast
Awadhiawa
Ayacucho Quechuaquy
Aymaraay
Aymara, Centralayr
Azerbaijaniaz
Azerbaijani, Northernazj
Azerbaijani, Southernazb
Balineseban
Bambarabm
Banjarbjn
Bashkirba
Batak Karobtx
Batak Simalungunbts
Batak Tobabbc
Basqueeu
Belarusianbe
Bembabem
Betawibew
Bikolbik
Bretonbr
Buryatbua
Bengalibn
Bhojpuribho
Bodobrx
Bosnianbs
Buginesebug
Bulgarianbg
Cantonese (Traditional)yue
Chuvashcv
Catalanca
Cebuanoceb
Chhattisgarhihne
Chinese (Literary)lzh
Chinese (Simplified)zh
Chinese (Traditional)zh-TW
Chokwecjk
Corsicanco
Crimean Tatarcrh
Croatianhr
Czechcs
Danishda
Darifa-AF
Dhivehi / Divehidv
Dimlidiq
Dinka (Southwestern)dik
Dombedov
Dogridoi
Dutchnl
Dyuladyu
Dzongkhadz
Englishen
Esperantoeo
Estonianet
Eweee
Faroesefo
Farsifa
Fijianfj
Filipino, Tagalogtl
Finnishfi
Fonfon
Frenchfr
French (Canada)fr-CA
Fulfulde (Fula, West Africa)ff
Frisianfy
Friulianfur
Gagaa
Galiciangl
Gandalg
Georgianka
Germande
Greekel
Gujaratigu
Haitian Creoleht
Hakha Chincnh
Halh Mongoliankhk
Hausaha
Hawaiianhaw
Hebrewhe
Hindihi
Hmonghmn
Hmong Dawmww
Hungarianhu
Hunsrikhrx
Icelandicis
Igboig
Ilocano / Ilokoilo
Indonesianid
Inuinnaqtuniu
Inuktitutikt
Inuktitut (Latin)iu-Latn
Irishga
Italianit
Japaneseja
Javanesejv
Jingphokac
Kabiyèkbp
Kabuverdianukea
Kabylekab
Kambakam
Kannadakn
Kanuri, Centralknc
Kapampanganpam
Kashmiri (Arabic)kas
Kashmiri (Devanagari)ks
Kazakhkk
Khmerkm
Kigacgg
Kikuyuki
Kimbundukmb
Kinyarwandarw
Kitubaktu
Kongokg
Konkanigom
Koreanko
Kriokri
Kurdishku
Kurdish (Kurmanji)kmr
Kurdish (Sorani)ckb
Kyrgyzky
Laolo
Latgalianltg
Latinla
Latvianlv
Ligurianlij
Limburgishli
Lingalaln
Lithuanianlt
Lombardlmo
Lower Sorbiandsb
Luba-Kasailua
Luoluo
Luxembourgishlb
Macedonianmk
Magahimag
Maithilimai
Makassarmak
Malagasymg
Malayms
Malay (Jawi)ms-Arab
Malayalamml
Maltesemt
Manipurimni
Maorimi
Marathimr
Meadow Marichm
Meiteilon (Manipuri)mni-Mtei
Minangkabaumin
Mizolus
Mongolianmn
Mongolian (Cyrillic)mn-Cyrl
Mongolian (Traditional)mn-Mong
Mossimos
Myanmar (Burmese)my
Ndebele (South)nr
Nepalbhasa (Newari)new
Nepaline
Nigerian Fulfuldefuv
Norwegian (Bokmål)no
Norwegian (Nynorsk)nn
Nuernus
Nyanja (Chichewa)ny
Occitanoc
Odia (Oriya)or
Oromoom
Oromo (West Central)gaz
Pangasinanpag
Papiamentopap
Pashtops
Polishpl
Pashto (Southern)pbt
Plateau Malagasyplt
Portuguese (Brazil)pt
Portuguese (Portugal)pt-PT
Punjabipa
Punjabi (Shahmukhi)pa-Arab
Quechuaqu
Queretaro Otomiotq
Romanirom
Romanianro
Rundirn
Russianru
Shonasn
Samoansm
Sangosg
Sanskritsa
Santalisat
Sardiniansc
Scots Gaelicgd
Sepedi (Northern Sotho)nso
Serbian (Cyrillic)sr-Cyrl
Serbian (Latin)sr-Latn
Sesotho (Southern Sotho)st
Seychellois Creolecrs
Shanshn
Sicilianscn
Silesianszl
Sindhisd
Sinhala (Sinhalese)si
Slovaksk
Sloveniansl
Somali (Latin)so-Latn
Somali (Arabic)so-Arab
Spanishes
Spanish (Latin America)es-419
Spanish (Mexico)es-MX
Standard Latvianlvs
Standard Malayzsm
Sundanesesu
Swahilisw
Swatiss
Swedishsv
Tahitianty
Tajiktg
Tamasheqtaq
Tamazight, Central Atlastzm
Tamilta
Tatar (Latin)tt-Latn
Tatar (Cyrillic)tt-Cyrl
Telugute
Tetumtet
Thaith
Tibetanbo
Tigrinyati
Tok Pisintpi
Tonganto
Tosk Albanianals
Tsongats
Tswana / Setswanatn
Tumbukatum
Turkishtr
Turkmentk
Twitw
Twi (Akan)ak
Ukrainianuk
Umbunduumb
Upper Sorbianhsb
Urduur
Uyghurug
Uzbek (Latin)uz
Uzbek (Northern)uzn
Venetianvec
Vietnamesevi
Waray (Philippines)war
Welshcy
Wolofwo
Xhosaxh
Yiddishyi
Yiddish (Eastern)ydd
Yorubayo
Yucatec Mayayua
Zuluzu
Arabic (Algerian)arq
Arabic (Egyptian)arz
Arabic (Gulf)afb
Arabic (Iraqi)acm
Arabic (Levantine)apc
Arabic (Moroccan)ary
Arabic (Tunisian)aeb
Aragonesean
Aromanianrup
Brajbra
Cantonese (Simplified)yue-Hans
Chinese (Singapore)zh-SG
Chittagonianctg
Cornishkw
Dutch (Belgium)nl-BE
English (Australia)en-AU
English (Canada)en-CA
English (India)en-IN
English (UK)en-GB
English (US)en-US
Fangfan
French (Belgium)fr-BE
French (France)fr-FR
French (Switzerland)fr-CH
Gagauzgag
German (Austria)de-AT
German (Germany)de-DE
German (Switzerland)de-CH
Guadeloupean Creolegcf
Guaranign
Guarani (Bolivia)gug
Hakkahak
Hiligaynon (Ilonggo)hil
Kanembukbl
Kashubiancsb
Khasikha
Kʼicheʼquc
Ladino (Judeo-Spanish)lad
Manxgv
Mapudungunarn
Mirandesemwl
Mundariunr
Nahuatl (Central)nhn
Nahuatl (Huasteca)nhw
Portuguese (Angola)pt-AO
Portuguese (Mozambique)pt-MZ
Punjabi (Gurmukhi)pa-Guru
Rajasthaniraj
Rohingyarhg
Romanshrm
Romansh Grischunrmh
Scotssco
Senufosen
Serbian (Serbia)sr-RS
Songhaison
Spanish (Argentina)es-AR
Spanish (Colombia)es-CO
Spanish (Spain)es-ES
Swahili (Kenya)sw-KE
Swahili (Tanzania)sw-TZ
Sylhetisyl
Tamil (Sri Lanka)ta-LK
Tigretig
Tivtiv
Ulster Scotssco-ULS
Uyghur (Arabic)ug-Arab
Uyghur (Latin)ug-Latn
Vendave
Walloonwa
Wu Chinese (Shanghainese)wuu
Showing 332 of 332 languages

AI Translation Models & Smart AI Translation

MachineTranslation.com runs up to 22 AI models at once, compares the outputs, and returns the best translation most of the AI models agree on (engine: "smart").

The custom instruction and glossary are sent to every engine in the consensus, on every path.

Currently Supported Translation Sources

Sources include, but are not limited to:

AI21Amazon TranslateAmazon NovaChatGPTAnthropic ClaudeDeepLDeepSeekFacebook (Meta)GeminiGLM (Z.ai)Google TranslateGrok (xAI)Kimi (MoonshotAI)LibreTranslateLingvanexLLaMA (Meta)Microsoft TranslatorMistral AIModernMTNiutransQwenRoyalflush