- v1.35.0Latest
- v1.35.0Latest
- v1.33.4
- v1.33.3
- v1.33.1
- v1.33.0
- v1.32.0
- v1.32.0
- v1.31.0
- v1.30.0
- v1.30.0
- v1.28.1
- v1.28.1
- v1.18.0
- v1.17.0
- v1.16.0
- v1.15.0
- v1.12.2
- v1.110
- v1.10.0
- v1.9.0
- v1.7.0
- v1.5.0
- v1.2.0
- v1.1.0
- v1.1.0
- v0.56.0-beta
- v0.51.0-beta
- v0.49.0-beta
- v0.48.0-beta
- v0.48.0-beta
- v0.45.0-beta
- v0.45.0-beta
- v0.44.0-beta
- v0.44.0-beta
- v0.43.0-beta
- v0.36.0-beta
- v0.31.0-beta
- v0.28.0-beta
- v0.27.0-beta
- v0.22.0-beta
- 0.19.4-alpha
Lago JavaScript Client
This is a JavaScript wrapper for Lago API. Works in Cloudflare Workers, Deno, and Node.js. Generated from the Lago Swagger document.
Installation
Install the lago-javascript-client via npm:
npm install lago-javascript-clientimport { Client, getLagoError } from 'lago-javascript-client';
const lagoClient = Client('__YOUR_API_KEY__');
try {
const { data } = await lagoClient.billableMetrics.createBillableMetric(billableMetric);
} catch (error) {
const lagoError = await getLagoError<typeof lagoClient.billableMetrics.createBillableMetric>(error);
}Compatibility
This SDK uses the Fetch API and natively supported Node.js version >= 18. For other Node versions:
Ideally, run Node with the
--experimental-fetchflagOtherwise, polyfill the Fetch API by doing both:
Pass a Fetch instance to the Lago client
import { Client } from 'lago-javascript-client'; import fetch from 'node-fetch'; const lagoClient = Client("api_key", { customFetch: fetch });
Usage
Check the Lago API reference
Error Handling
Use the get getLagoError<>() utility function to extract the error object and TypeScript type:
try {
const { data } = await lagoClient.billableMetrics.createBillableMetric(billableMetric);
} catch (error) {
const lagoError = await getLagoError<typeof lagoClient.billableMetrics.createBillableMetric>(error);
}Development
Uses dnt to build and test for Deno and Node.
Dependencies
Requires Deno and Node.js >= 18
Run tests
deno task testBuild
deno task buildPublish to NPM
deno task build
cd npm
npm publishDocumentation
The Lago documentation is available at doc.getlago.com.
Contributing
The contribution documentation is available here
License
Lago Node.js client is distributed under AGPL-3.0.