Official Node interface for the Lokalise API.
Looking for a simple way to upload/download translations? Try lokalise-file-exchange.
Heads up: starting from v9, this SDK is pure ESM and no longer ships a CommonJS (require) export. Your options:
- convert your project to ESM (see this guide)
- use dynamic import (example below)
- or stay on v8
Install:
npm install @lokalise/node-apiGet a Lokalise API token from your personal profile, then initialize and use the client:
import { LokaliseApi } from "@lokalise/node-api";
const lokaliseApi = new LokaliseApi({ apiKey: "<apiKey>" });
const projects = await lokaliseApi.projects().list();
projects.items[0].name;
const process = await lokaliseApi.files().upload(project_id, {
data: data_base64,
filename: "test1.json",
lang_iso: "en",
});
process.status; // => "queued"Alternatively, you can use tokens obtained via OAuth2 (note: OAuth tokens expire):
import { LokaliseApiOAuth } from "@lokalise/node-api";
const lokaliseApi = new LokaliseApiOAuth({ apiKey: "<apiKeyObtainedViaOauth2>" });
const projects = await lokaliseApi.projects().list();Dynamic import example:
(async function () {
const LokaliseApi = await import("@lokalise/node-api").then((m) => m.LokaliseApi);
const lokaliseApi = new LokaliseApi({ apiKey: LOKALISE_API_TOKEN });
// use lokaliseApi here as usual...
})();Full docs live at: lokalise.github.io/node-lokalise-api.
Also useful:
- repo containing some usage examples
- blog post with explanations
- free course "Lokalise for developers" (Node SDK usage)
This library is licensed under the BSD 3 Clause. Prior to version 5.1.0 the license was MIT.
Copyright (c) Lokalise group and Ilya Krukowski