Lokalise APIv2 Node SDK

Node interface for the Lokalise APIv2.

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




Exception handling

To handle request errors, you can use the following approach:

lokaliseApi.projects().list().catch(
  (e) => {
    console.log(e);
  }
);

Or with async/await:

import { ApiError } from "@lokalise/node-api";

try {
  await lokaliseApi.projects().list();
} catch (e) {
  console.error(e);
  if (error instanceof ApiError) {
    console.log(e.message); // "Request timed out after 1000ms"
    console.log(e.code); // 408
    console.log(e.details); // { reason: "timeout" }
  }
}

Error codes are listed in the API docs.

API Rate Limits

Access to all endpoints is limited to 6 requests per second from 14 September, 2021. This limit is applied per API token and per IP address. If you exceed the limit, a 429 HTTP status code will be returned and the corresponding exception will be raised that you should handle properly. To handle such errors, we recommend an exponential backoff mechanism with a limited number of retries.