rate-limiter-api
Rate limits, handled with care

Stay within
the limit.

Queue API requests, respect the quota, and keep your app moving. One small library with a modern Promise API and a maintained compatibility release.

Try the playground
2.0.0 latest 1.0.12 legacy support View on npm
REQUEST FLOW LIVE
↗Incoming
08
queue
Rate limiter2 in flight · 4 queued
✓
controlled
✓To API
02
Window budget
4 / 6
✓ quota respected
◷ resumes on reset
BUILT FOR THE UNPREDICTABLEREQUESTS IN · CONTROL OUT ↓
01 Reserve quota before dispatch02 Queue until the next reset03 Choose callbacks or Promises04 Keep the old API on 1.x

THE SMALL THING THAT HELPS

Make every request count.

Give the limiter your provider’s quota headers. It reserves capacity as work starts, holds queued calls when the budget runs out, and resumes when the provider window resets.

01 / SET THE RULES
concurrency: 2

Choose your pace

Set a safety threshold, concurrency, and a burst first or uniform strategy.

02 / QUEUE YOUR WORK
→0102

Send without guessing

Hand each operation to limit(). The scheduler dispatches only what the budget allows.

03 / KEEP MOVING
◷reset

Resume at reset

When the provider’s window opens again, the waiting queue continues on its own.

INTERACTIVE PLAYGROUND

See the queue
in motion.

This runs the published 2.0.0 browser bundle with simulated requests. Nothing is sent to an external API.

3 requests10 requests
1 at a time4 at a time

Connecting to the published package…

SIMULATED APIRequest monitor
Ready
COMPLETED0 / 0
IN FLIGHT0
WAITING0
WINDOW CAPACITY6 available
Resets in —Headroom 1 request
↘Your queue is clear.Run a batch to watch requests pass through.
Powered by rate-limiter-api@2.0.0

GET STARTED

Two release lines.
One clear choice.

New projects should start on 2.x. Existing projects can stay on the callback-compatible 1.x line and receive maintenance updates.

02 CURRENT

Modern API

Promise-based, typed, and ready for current Node.js.

npm install rate-limiter-api
v2.0.0Node.js 22+Docs & package ↗
01 COMPATIBILITY

Callback API

Preserves the original Stampit-style factory and callback behavior.

npm install rate-limiter-api@legacy
v1.0.12Node.js 6+Docs & package ↗
// Queue a request and keep a little quota in reserve
const limiter = RateLimiterAPI({
  threshold: 1,
  concurrency: 2,
})

limiter.updateRateLimits({
  rateLimit: 60,
  rateRemaining: 42,
  rateReset: Date.now() + 60_000,
})

const result = await limiter.limit(() => fetch('/api/data'))
⌁Small surface arealimit() · updateRateLimits() · getRateLimits()
◷Provider awareUses the reset time you pass in
↗Typed and testedBuilt from a shared scheduler
Read the API guide