The Lilt REST API can be used to easily automate the uploading, translation, and downloading of files within Lilt.

Note: To be able to make use of the File Translation API, you must have access to your Lilt API key. The Lilt API key is only available to business accounts. See how to obtain your API key here.

Upload files

File upload via the API is done by making a POST request, commonly made via the command line tool CURL. To make a POST request, you need to know the following information:

  • your API key
  • the local path of the file to upload (for example: C:/Users/Example/Documents/example.txt)

The CURL command to upload a file should look like this:

curl -X POST "https://lilt.com/2/files?key=[KEY]&name=[FILE NAME]" --header "Content-Type: application/octet-stream" --data-binary @[LOCAL FILE PATH]

In the example above, you would need to replace [FILE NAME] with the desired file name and [LOCAL FILE PATH] with the local file path of the file you want to upload.

See the Lilt API Documentation for additional request parameters that can be included in the POST request.

Once you have successfully uploaded a file, you will receive a response confirming all the options you indicated in the upload process, as well as a file ID, denoted by id.

Translate files

To have Lilt translate the document you uploaded, you will have to make another POST request using the file ID (that you received in the upload step), your API key, and the Memory ID being used to translate.

To obtain the Lilt Memory ID, navigate to the Memories tab, open the desired Lilt Memory, and open the Settings page to view the Lilt Memory's ID.

The CURL command to start the translation should look like this:

curl -X POST "https://lilt.com/2/translate/file?fileId=[FILE ID]&memoryId=[MEMORY ID]&key=[KEY]"

In the example above, you would need to replace [FILE ID], [MEMORY ID], and [KEY] with your file ID, Memory ID and API key respectively. If you wish to begin multiple translations at once, write in each of the file IDs separated by commas.

Note: You may be asked to include a Content-length header. If this is the case, simply append the following to your command:

--header "Content-length:0"

See an example of how to start machine translation of a file here.

Once a file has been sent off for translation, you will receive a response with the following information:

  • The options you gave.
  • A translation ID (listed as id in the response). Note that this is distinct from the file ID.

Checking File Translation Status

If you are uploading and translating a large amount of files or very large files, it can be useful to check on their translation progress. This is especially the case if you wish to automatically download them, because you don't want to download them before they have been translated. To check if a file has been translated, you will need your API key and the translation ID (that you received in the translation step).

The CURL command to get the status of the file should look like this:

curl "https://lilt.com/2/translate/file?&key=[KEY]&translationIds=[TRANSLATION IDS]"

In this example, [KEY] is your API key and [TRANSLATION IDS] are the translation IDs from any number of translations which have been initiated. For multiple translation ID values, separate them by commas. The response will include the following information:

  • translation ID
  • file ID
  • status (InProgress, Completed, Failed, or ReadyForDownload)
  • time at which it was created (in Unix time)

Download Files

Once a file has the status ReadyForDownload, you can download it with the following command.

curl "https://lilt.com/2/translate/files?id=[TRANSLATION ID]&key=[KEY]" > [DESTINATION_FILE]

In this example, [TRANSLATION ID] is the translation ID (that you received in the translation step), [KEY] is your API key, and [DESTINATION_FILE] is the name of either an existing local file you wish to overwrite or a new file you wish to create.