Skip to main content
POST
/
v2
/
translate
Translate a segment
curl --request POST \
  --url https://api.lilt.com/v2/translate \
  --header 'Authorization: Basic <encoded-value>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "memory_id": 123,
  "source": "<string>",
  "source_hash": 123,
  "n": 123,
  "prefix": "<string>",
  "rich": false,
  "tm_matches": true,
  "project_tags": false,
  "containsICUData": false
}
'
import requests

url = "https://api.lilt.com/v2/translate"

payload = {
"memory_id": 123,
"source": "<string>",
"source_hash": 123,
"n": 123,
"prefix": "<string>",
"rich": False,
"tm_matches": True,
"project_tags": False,
"containsICUData": False
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
memory_id: 123,
source: '<string>',
source_hash: 123,
n: 123,
prefix: '<string>',
rich: false,
tm_matches: true,
project_tags: false,
containsICUData: false
})
};

fetch('https://api.lilt.com/v2/translate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.lilt.com/v2/translate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'memory_id' => 123,
'source' => '<string>',
'source_hash' => 123,
'n' => 123,
'prefix' => '<string>',
'rich' => false,
'tm_matches' => true,
'project_tags' => false,
'containsICUData' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.lilt.com/v2/translate"

payload := strings.NewReader("{\n \"memory_id\": 123,\n \"source\": \"<string>\",\n \"source_hash\": 123,\n \"n\": 123,\n \"prefix\": \"<string>\",\n \"rich\": false,\n \"tm_matches\": true,\n \"project_tags\": false,\n \"containsICUData\": false\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.lilt.com/v2/translate")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"memory_id\": 123,\n \"source\": \"<string>\",\n \"source_hash\": 123,\n \"n\": 123,\n \"prefix\": \"<string>\",\n \"rich\": false,\n \"tm_matches\": true,\n \"project_tags\": false,\n \"containsICUData\": false\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.lilt.com/v2/translate")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"memory_id\": 123,\n \"source\": \"<string>\",\n \"source_hash\": 123,\n \"n\": 123,\n \"prefix\": \"<string>\",\n \"rich\": false,\n \"tm_matches\": true,\n \"project_tags\": false,\n \"containsICUData\": false\n}"

response = http.request(request)
puts response.read_body
{
  "untokenizedSource": "Authentication not required.",
  "tokenizedSource": "Authentication not required .",
  "sourceDelimiters": [
    "",
    " ",
    " ",
    "",
    ""
  ],
  "translation": [
    [
      {
        "score": 3.4936864e-8,
        "align": "0-0 1-1 2-2 3-3",
        "targetDelimiters": [
          "",
          " ",
          " ",
          "",
          ""
        ],
        "targetWords": [
          "Authentifizierung",
          "nicht",
          "erforderlich",
          "."
        ],
        "target": "Authentifizierung nicht erforderlich .",
        "targetWithTags": "Authentifizierung nicht erforderlich.",
        "isTMMatch": false,
        "provenance": "0 0 0 0"
      }
    ]
  ]
}
"<string>"
{
"message": "Internal server error."
}

Authorizations

Authorization
string
header
required

Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.

Body

application/json
memory_id
integer
required

A unique Memory identifier.

source
string

A unique Segment identifier.

source_hash
integer

A source hash code.

n
integer

Return top n translations (deprecated).

prefix
string

A target prefix

rich
boolean
default:false

Returns rich translation information (e.g., with word alignments).

tm_matches
boolean
default:true

Include translation memory fuzzy matches.

project_tags
boolean
default:false

Project tags. Projects tags in source to target if set to true.

containsICUData
boolean
default:false

Contains ICU data. If true then tags in the source following the ICU standard will be parsed and retained.

Response

A TranslationList object.

An ranked list of translations and associated metadata.

untokenizedSource
string

The untokenized source segment. Punctuation has not been separated from words.

Example:

"Authentication not required."

tokenizedSource
string

The tokenized source segment. Punctuation has been separated from words.

Example:

"Authentication not required ."

sourceDelimiters
string[]

A format string that indicates, for each word, if the word should be preceded by a space.

Example:
["", " ", " ", "", ""]
translation
object[]

A list of Translation objects.