@lokalise/node-api
TypeScript icon, indicating that this package has built-in type declarations

12.8.0 • Public • Published

Lokalise API v2 official Node.js client

npm CI Coverage Status Downloads total

Official Node interface for the Lokalise API.

Quickstart

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 (please find an example below), or stay on version 8.

Install the library:

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();

Here's an example using dynamic import:

(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...
})();

Usage

Detailed documentation can be found at lokalise.github.io/node-lokalise-api.

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.

License

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

/@lokalise/node-api/

    Package Sidebar

    Install

    npm i @lokalise/node-api

    Weekly Downloads

    100,746

    Version

    12.8.0

    License

    BSD-3-Clause

    Unpacked Size

    755 kB

    Total Files

    457

    Last publish

    Collaborators

    • mmounirf
    • dariacm
    • forter_lokalise
    • andrew_lokalise
    • carlos_gamero
    • kibertoad
    • arthuracs
    • yury.kravtsov
    • filippos.mikropoulos
    • aplokalise
    • botlokalise
    • laurislokalise
    • marcocardosolok
    • bodrovis