Lokalise APIv2 Node SDK

Node interface for the Lokalise APIv2.

View the Project on GitHub lokalise/node-lokalise-api




Translation files

File attributes

Fetch translation files

API doc

const files = await lokaliseApi.files().list({
  project_id: project_id,
  page: 3,
  limit: 4
});

files.items[0].filename;

Download translation files

API doc

Exports project files as a .zip bundle and makes them available to download (the link is valid for 12 months).

const response = await lokaliseApi.files().download(project_id,
  {format: 'json', "original_filenames": true}
);

response.bundle_url;

Download translation files (async)

API doc

Starts a project export process.

const projectId = "123.abc";
const process = await lokaliseApi.files().async_download(projectId,
  {format: 'json', "original_filenames": true}
);

const process_id = process.process_id;

Once complete, the download URL can be accessed using the Retrieve process API endpoint:

const processInfo = await lokaliseApi
  .queuedProcesses()
  .get(process_id, { project_id: projectId });

processInfo.type; // => "async-export"
processInfo.status; // => "finished"
processInfo.details.total_number_of_keys; // => 14
processInfo.details.download_url // => "https://lokalise-live-lok-s3-fss-export.s3.eu-central-1.amazonaws.com/..."

Upload translation file

API doc

Background uploading is the only method of importing files since July 2020.

process = await lokaliseApi.files().upload(project_id,
  {data: data_base64, filename: 'test1.json', lang_iso: 'en'}
);
process.status; // => 'queued'

Asynchronous upload will return a QueuedProcess containing process ID, status of the process (queued, finished, failed etc) and some other info. You may periodically check the status of the process by using get() method:

process = await lokaliseApi.files().upload(project_id,
  {data: data_base64, filename: 'test1.json', lang_iso: 'en'}
);

// You'll obtain `process_id` after calling `files.upload()`
process = await lokaliseApi.queuedProcesses().get(process.process_id, { project_id: project_id })

process.status // => 'finished'

Delete translation file

API doc

Please note that this endpoint does not support “software localization” projects.

const response = await lokaliseApi.files().delete(file_id,
  { project_id: project_id }
);

response.project_id // => "123.abc"
response.file_deleted // => true