https://github.com/lokalise/node-lokalise-api
Lokalise API v2 Node.js client.
https://github.com/lokalise/node-lokalise-api
api client inteface lokalise lokalise-api node sdk sdk-node translation-providers
Last synced: 2 months ago
JSON representation
Lokalise API v2 Node.js client.
- Host: GitHub
- URL: https://github.com/lokalise/node-lokalise-api
- Owner: lokalise
- License: other
- Created: 2018-10-15T15:47:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-05-07T16:06:55.000Z (10 months ago)
- Last Synced: 2025-05-07T17:23:58.753Z (10 months ago)
- Topics: api, client, inteface, lokalise, lokalise-api, node, sdk, sdk-node, translation-providers
- Language: TypeScript
- Homepage: https://lokalise.github.io/node-lokalise-api
- Size: 3.35 MB
- Stars: 63
- Watchers: 20
- Forks: 21
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-list - node-lokalise-api
README
# Lokalise API v2 official Node.js client


[](https://coveralls.io/github/lokalise/node-lokalise-api?branch=master)
[![NPM Downloads][npm-downloads-image]][npm-downloads-url]
Official Node interface for the [Lokalise API](https://app.lokalise.com/api2docs/curl/#resource-getting-started).
> Looking for a simple way to upload/download translations? Try [lokalise-file-exchange](https://github.com/bodrovis/lokalise-node-file-exchange).
## Quickstart
**Heads up:** starting from **v9**, this SDK is **pure [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)** and no longer ships a CommonJS (`require`) export. Your options:
- convert your project to ESM ([see this guide](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c))
- use [dynamic import](https://v8.dev/features/dynamic-import) (example below)
- or stay on [v8](https://github.com/lokalise/node-lokalise-api/tree/v8)
Install:
```bash
npm install @lokalise/node-api
```
[Get a Lokalise API token from your personal profile](https://docs.lokalise.com/en/articles/1929556-api-and-ota-tokens#h_9ea8e7ff3c), then initialize and use the client:
```ts
import { LokaliseApi } from "@lokalise/node-api";
const lokaliseApi = new LokaliseApi({ 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](https://lokalise.github.io/node-lokalise-api/additional_info/oauth2_flow) (*note: OAuth tokens expire*):
```ts
import { LokaliseApiOAuth } from "@lokalise/node-api";
const lokaliseApi = new LokaliseApiOAuth({ apiKey: "" });
const projects = await lokaliseApi.projects().list();
```
Dynamic import example:
```ts
(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
Full docs live at: [lokalise.github.io/node-lokalise-api](https://lokalise.github.io/node-lokalise-api/).
Also useful:
- [repo containing some usage examples](https://github.com/bodrovis-learning/Lokalise-APIv2-Samples)
- [blog post with explanations](https://lokalise.com/blog/lokalise-apiv2-in-practice)
- [free course "Lokalise for developers"](https://academy.lokalise.com/course/lokalise-for-developers) (Node SDK usage)
## License
This library is licensed under the [BSD 3 Clause](https://github.com/lokalise/node-lokalise-api/blob/master/LICENSE). Prior to version 5.1.0 the license was MIT.
Copyright (c) [Lokalise group](http://lokalise.com) and [Ilya Krukowski](http://bodrovis.tech)
[npm-downloads-image]: https://img.shields.io/npm/dm/%40lokalise%2Fnode-api
[npm-downloads-url]: https://npmcharts.com/compare/@lokalise/node-api?minimal=true