npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@limityourapi/node

v3.0.1

Published

Official Node.js SDK for LimitYourAPI — API Revenue Infrastructure. Quota enforcement, billing sync, and AI cost protection.

Downloads

103

Readme

@limityourapi/node

Official Node.js SDK for LimitYourAPI — API Revenue Infrastructure for quota enforcement, billing sync, and AI cost protection.

npm version License: Apache 2.0 Node.js

LimitYourAPI lets you meter usage, enforce entitlements, sync customer billing states, and protect AI budgets with sub-millisecond decision latency.


1. What is LimitYourAPI?

LimitYourAPI is API Revenue Infrastructure designed to sit in your API path. Instead of just blocking bad actors, it maps API keys to Stripe/Razorpay subscriptions, tracks consumer usage profiles in real-time, alerts on quota thresholds, and implements limits on high-cost AI tokens or computational endpoints before they occur.


2. Why not Redis?

While you can build basic rate limiting in Redis using custom scripts:

  • No Bounded Logic: Custom Redis scripts do not have a built-in state management for Stripe pricing tables, trial durations, or tier features.
  • Race Conditions: Implementing multiple concurrent limits (e.g. daily quota + concurrent burst protection) across different meters is complex and prone to latency/race bugs.
  • Fail-Open Complexity: Writing fail-safe edge routing, backoffs, and circuit breaking in your app code takes weeks of engineering.
  • No Observability: Redis does not provide out-of-the-box usage pipelines, Stripe sync triggers, or upgrade signals.

LimitYourAPI abstracts this database hot-path logic into a single sub-millisecond check.


3. Install

Install the package via npm:

npm install @limityourapi/node

Ensure you have Node.js 18 or higher (uses native, zero-dependency fetch).


4. First enforce()

Import the client and verify customer entitlements against a meter:

import LimitYourAPI from "@limityourapi/node";

const limit = new LimitYourAPI({
  apiKey: process.env.LIMIT_API_KEY, // rl_...
});

const result = await limit.enforce({
  customer: "cus_98234",
  meter: "api_calls",
  consume: 1
});

console.log(result.allowed); // true
console.log(result.remaining); // 9999
console.log(result.resetIn); // 172635

5. Billing example

Link customer usage directly to Stripe plans:

const result = await limit.enforce({
  customer: "cus_123",
  meter: "api_calls",
  consume: 10,
  route: "/v1/inference"
});

if (!result.allowed && result.upgradeAvailable) {
  console.log(`Plan ${result.plan} usage limits hit. Redirecting customer to Stripe upgrade...`);
  // Redirect to result.reason or Stripe Portal
}

6. AI token example

Prevent runaway LLM costs by tracking token usage before processing:

// Estimate token usage (e.g. using tiktoken)
const tokensRequired = 2500;

const result = await limit.enforce({
  customer: "cus_123",
  meter: "ai_tokens",
  consume: tokensRequired
});

if (!result.allowed) {
  throw new Error("AI budget warning: Monthly AI token limit exceeded.");
}

// Call your OpenAI / Anthropic models safely...

7. Dashboard preview

Monitor revenue protection, upgrade signals, AI token spend, and active API customer rollups inside the Stripe-inspired LimitYourAPI Dashboard V3:

  • Revenue Protected: Value of consumption checked and safely metered.
  • API Customers: Interactive list of consuming identifiers and plan states.
  • Upgrade Opportunities: Real-time listing of customers nearing 80%+ limit usage.
  • AI Cost Protected: USD projections of LLM token usages.

8. SDK Links


License

Apache-2.0 © LimitYourAPI