Lokalise APIv2 Node SDK

Node interface for the Lokalise APIv2.

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




Lokalise APIv2 Node interface

Please note that starting from version 9 this SDK is a pure ESM module. It does not provide a CommonJS export (require) anymore. Therefore you should either convert your project to ESM, use dynamic import, or stay on version 8 which we are fully supporting.

Install the library using NPM:

npm install @lokalise/node-api

Obtain Lokalise API token in your personal profile, 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;

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 (don’t forget that these tokens have expiration dates):

import { LokaliseApiOAuth } from '@lokalise/node-api';

const lokaliseApi = new LokaliseApiOAuth({ apiKey: '<apiKeyObtainedViaOauth2>' });

const projects = lokaliseApi.projects().list();

You can also check this repo containing some usage examples and this blog post with explanations. Finally, you might be interested in our free course “Lokalise for developers” that showcases Node SDK usage.

Usage

Additional info