New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lago-javascript-client

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lago-javascript-client

Lago JavaScript API Client

  • 1.22.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Lago JavaScript Client

This is a JavaScript wrapper for Lago API. Works in Cloudflare Workers, Deno, and Node.js. Generated from the Lago OpenAPI document.

PyPI version License: MIT

Current Releases

ProjectRelease Badge
LagoLago Release
Lago JavaScript ClientLago JavaScript Client Release

Installation

For npm users:

npm install lago-javascript-client
// npm
import { Client, getLagoError } from 'lago-javascript-client';

// Deno
import { Client, getLagoError } from 'https://deno.land/x/lago/mod.ts';

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:

  1. Ideally, run Node with the --experimental-fetch flag

  2. Otherwise, polyfill the Fetch API by doing both:

    1. Patching globalThis

    2. 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.

Release new version

Change the affected fields in scripts/build_npm.ts and commit to GitHub. GitHub Actions will build and deploy to npm.

Dependencies

Requires Deno and Node.js >= 18

Generate client from OpenAPI

deno task generate:openapi

Run tests

deno task test

Build

deno task build

Publish to npm

deno task build
cd npm
npm publish

Documentation

The Lago documentation is available at doc.getlago.com.

Contributing

The contribution documentation is available here

License

Lago JavaScript client is distributed under MIT license.

Keywords

FAQs

Package last updated on 25 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc