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

v1.0.0

Published

Official Node.js SDK for LimitYourAPI — production-grade API rate limiting as a service. Express middleware, fail-open, zero dependencies.

Readme

limityourapi

Official Node.js SDK for LimitYourAPI — production-grade API rate limiting as a service.

npm version License: MIT Node.js

Add enterprise-grade rate limiting to any Node.js app in 2 lines. Zero dependencies. Fail-open by default. TypeScript support included.

✨ Features

  • 🚀 2-line setup — Express middleware included
  • 📦 Zero dependencies — uses native fetch (Node 18+)
  • 🛡️ Fail-open — your app stays up even if the limiter is down
  • 🔧 TypeScript — full type definitions included
  • Edge support — optional edge-first routing for global apps
  • 🪣 Token & cost-based — AI/LLM endpoint support built-in

Installation

npm install limityourapi

Quick Start

import { LimitYourAPIClient } from 'limityourapi';

const limiter = new LimitYourAPIClient({
  baseUrl: 'https://limityourapi.onrender.com',
  apiKey: process.env.LIMITYOURAPI_KEY, // rl_...
});

Express Middleware (recommended)

import express from 'express';
import { LimitYourAPIClient } from 'limityourapi';

const app = express();
const limiter = new LimitYourAPIClient({
  baseUrl: 'https://limityourapi.onrender.com',
  apiKey: process.env.LIMITYOURAPI_KEY,
});

// Protect all routes — one line!
app.use(limiter.middleware());

// Or protect specific routes
app.get('/api/sensitive',
  limiter.middleware({ endpoint: '/api/sensitive' }),
  (req, res) => res.json({ data: 'protected' })
);

app.listen(3000);

Direct Check

const result = await limiter.check({ endpoint: '/api/users' });

console.log(result);
// {
//   allowed: true,
//   remaining: 98,
//   resetIn: 55,
//   limit: 100,
//   rule: "Default API Limit",
//   status: 200
// }

if (!result.allowed) {
  console.log(`Rate limited! Retry in ${result.resetIn}s`);
}

Token/Cost-Based Limiting (for AI endpoints)

const result = await limiter.checkWithTokens({
  endpoint: '/api/ai/generate',
  tokens: 150,    // tokens consumed
  cost: 0.003,    // estimated cost in $
});

console.log(result.remainingTokens);  // tokens left in window
console.log(result.remainingBudget);  // budget left in window

Middleware Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | endpoint | string | req.path | Fixed endpoint to check | | failOpen | boolean | true | Allow requests if limiter is down | | onBlocked | function | null | Custom 429 handler | | getTokenCount | function | null | Extract token count from request | | getEstimatedCost | function | null | Extract cost from request |

Custom Block Handler

app.use(limiter.middleware({
  onBlocked: (req, res, result) => {
    res.status(429).json({
      error: 'Slow down!',
      retry_after: result.resetIn,
      upgrade_url: 'https://limityourapi.onrender.com/pricing',
    });
  },
}));

Response Headers

The middleware automatically sets these standard headers:

| Header | Description | |--------|-------------| | X-RateLimit-Limit | Maximum requests allowed | | X-RateLimit-Remaining | Requests remaining in window | | X-RateLimit-Reset | Seconds until window resets |

Fail-Open Behavior

By default, if the rate limiter service is unreachable or times out, requests are allowed through (fail-open). This ensures your app stays available even during limiter outages.

// Override: reject requests when limiter is down
app.use(limiter.middleware({ failOpen: false }));

Client Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | baseUrl | string | required | LimitYourAPI service URL | | apiKey | string | required | Your API key (rl_...) | | timeout | number | 5000 | Request timeout in ms | | edgeUrl | string | null | Edge endpoint URL | | useEdge | boolean | false | Route via edge first |

Getting Your API Key

  1. Sign up at LimitYourAPI Dashboard
  2. Navigate to API KeysCreate Key
  3. Copy your key (starts with rl_)

Or via CLI:

# Register
curl -X POST https://limityourapi.onrender.com/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","password":"SecurePass123!"}'

# Login
TOKEN=$(curl -s -X POST https://limityourapi.onrender.com/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","password":"SecurePass123!"}' | jq -r '.token')

# Create API Key
curl -X POST https://limityourapi.onrender.com/apikeys \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"my-app"}'

License

MIT © Yash