JavaScript rate limiting libraries

Updated Nov 2026

JavaScript rate limiting libraries cap how often a client can call an endpoint or how fast a program starts outgoing work. A limiter counts requests per key in a time window or token bucket and rejects or delays any request over the budget. These libraries protect APIs from abuse and keep AI agents inside third-party API quotas.

Popularity

express-rate-limit has the most monthly downloads in this comparison, at 365.8M.

LibraryMonthly downloadsStarsLast releaseLicense
express-rate-limit
374.0M
3.3KNov 2026MIT
limiter
89.9M
1.6KSep 2026MIT
bottleneck
59.2M
2.0KAug 2019MIT
@nestjs/throttler
24.8M
Not on GitHubNov 2026MIT
@fastify/rate-limit
19.6M
Not on GitHubNov 2026MIT
rate-limiter-flexible
18.2M
3.6KNov 2026ISC
@upstash/ratelimit
12.8M
Not on GitHubNov 2026MIT
koa2-ratelimit
1.1M
Not on GitHubMar 2023MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryShared quota backendAutomatic HTTP quota headersTask callback scheduling
express-rate-limitVia pluginBuilt-inUnsupported
limiterUnsupportedUnsupportedUnsupported
bottleneckBuilt-inUnsupportedBuilt-in
@nestjs/throttlerVia pluginBuilt-inUnsupported
@fastify/rate-limitBuilt-inBuilt-inUnsupported
rate-limiter-flexibleBuilt-inUnsupportedUnsupported
@upstash/ratelimitBuilt-inUnsupportedUnsupported
koa2-ratelimitBuilt-inBuilt-inUnsupported
Built-inVia pluginNot supported

Libraries and code examples

express-rate-limit

Adds request-count limits to Express routes and middleware.

Downloads / mo
374.0M
Stars
3.3K
Last release
8.7.5
License
MIT

Strengths

  • Limits public endpoints directly. Mount the middleware on password-reset routes or an entire API.
  • Shares counters through store adapters. Use an external store across multiple processes or servers.

Limitations

  • Default counters reset on restart. Use an external store when request counts must survive restarts.
  • One limiter uses one window. Create separate limiters for multiple time windows.

Quickstart

From readme.md
$ npm install express-rate-limit@8.7.5 express
import express from 'express';
import { rateLimit } from 'express-rate-limit';
const app = express();
app.use(rateLimit({ windowMs: 60_000, limit: 10 }));
app.get('/', (_req, res) => res.send('hello'));
app.listen(3000);

express-rate-limit examples

From open-source projects on GitHub

Paces work with interval limits and hierarchical token buckets.

Downloads / mo
89.9M
Stars
1.6K
Last release
4.1.0
License
MIT

Strengths

  • Waits or rejects immediately. Use removeTokens to wait and tryRemoveTokens to check capacity immediately.
  • Shares parent and child budgets. A successful token removal charges the child and its finite ancestors.

Limitations

  • Counters stay within one instance. Processes, workers, and machines need a separate shared-limit solution.
  • Limits starts rather than concurrency. Use a separate limiter to cap simultaneous in-flight work.

Quickstart

From README.md
$ npm install limiter@4.1.0
import { RateLimiter } from 'limiter';
const limiter = new RateLimiter({ tokensPerInterval: 1, interval: 'second' });
console.log(await limiter.removeTokens(1));

limiter examples

From open-source projects on GitHub

Queues jobs and controls their start rate and simultaneous execution.

Downloads / mo
59.2M
Stars
2.0K
Last release
2.19.5
License
MIT

Strengths

  • Controls simultaneous work. Set maxConcurrent alongside minTime to pace jobs and cap concurrency.
  • Creates separate limits per key. Use Group to manage independent limiters for different clients.

Limitations

  • Queued jobs disappear on exit. Redis shares limiter state, but queued jobs remain in the process.
  • Retries keep concurrency slots occupied. A waiting retry still counts toward maxConcurrent.

Quickstart

From README.md
$ npm install bottleneck@2.19.5
import Bottleneck from 'bottleneck';
const limiter = new Bottleneck({ minTime: 100, maxConcurrent: 1 });
console.log(await limiter.schedule(() => Promise.resolve('hello')));

bottleneck examples

From open-source projects on GitHub

@nestjs/throttler

Adds endpoint quotas to NestJS through a guard, module, and decorators.

Downloads / mo
24.8M
Last release
6.8.0
License
MIT

Quickstart

From README.md
$ npm install @nestjs/throttler@6.8.0 @nestjs/common@^11 @nestjs/core@^11 @nestjs/platform-express@^11 reflect-metadata rxjs
import 'reflect-metadata';
import { Controller, Get, Module } from '@nestjs/common';
import { APP_GUARD, NestFactory } from '@nestjs/core';
import { ThrottlerGuard, ThrottlerModule } from '@nestjs/throttler';

@Controller()
class HelloController {
  @Get() hello() { return 'hello'; }
}
@Module({
  imports: [ThrottlerModule.forRoot([{ ttl: 60_000, limit: 10 }])],
  controllers: [HelloController],
  providers: [{ provide: APP_GUARD, useClass: ThrottlerGuard }],
})
class AppModule {}
const app = await NestFactory.create(AppModule);
await app.listen(3000);

@nestjs/throttler examples

From open-source projects on GitHub

@fastify/rate-limit

Limits Fastify routes with optional Redis integration and custom request keys.

Downloads / mo
19.6M
Last release
11.2.2
License
MIT

Quickstart

From README.md
$ npm install @fastify/rate-limit@11.2.2 fastify@^5
import Fastify from 'fastify';
import rateLimit from '@fastify/rate-limit';
const app = Fastify();
await app.register(rateLimit, { max: 10, timeWindow: '1 minute' });
app.get('/', async () => 'hello');
await app.listen({ port: 3000 });

rate-limiter-flexible

Enforces per-key quotas using memory, clustered workers, or shared stores.

Downloads / mo
18.2M
Stars
3.6K
Last release
11.5.0
License
ISC

Strengths

  • Limits users or API keys. Consume points against an IP, user ID, or another string key.
  • Coordinates workers through IPC. RateLimiterCluster sends worker requests to one process that handles limits.

Limitations

  • Store clients need separate setup. Create a database or cache connection before using its store limiter.
  • Distributed queues can reorder requests. Strict FIFO is guaranteed only with Memory and Cluster limiters.

Quickstart

From README.md
$ npm install rate-limiter-flexible@11.5.0
import { RateLimiterMemory } from 'rate-limiter-flexible';
const limiter = new RateLimiterMemory({ points: 10, duration: 60 });
console.log(await limiter.consume('example-user'));

@upstash/ratelimit

Checks quotas through Redis REST calls from HTTP and serverless hosts.

Downloads / mo
12.8M
Last release
2.2.1
License
MIT

Quickstart

From README.md
$ npm install @upstash/ratelimit@2.2.1 @upstash/redis
import { Ratelimit } from '@upstash/ratelimit';
import { Redis } from '@upstash/redis';
const limiter = new Ratelimit({ redis: Redis.fromEnv(), limiter: Ratelimit.slidingWindow(10, '10 s') });
console.log(await limiter.limit('example-user'));

@upstash/ratelimit examples

From open-source projects on GitHub

koa2-ratelimit

Adds rate limiting middleware to Koa with optional Redis, Sequelize, or Mongoose stores.

Downloads / mo
1.1M
Last release
1.1.3
License
MIT

Quickstart

From README.md
$ npm install koa2-ratelimit@1.1.3 koa
const Koa = require('koa');
const { RateLimit } = require('koa2-ratelimit');
const app = new Koa();
app.use(RateLimit.middleware({ interval: { min: 1 }, max: 10 }));
app.use(ctx => { ctx.body = 'hello'; });
app.listen(3000);

FAQ

express-rate-limit suits Express servers that limit incoming requests. rate-limiter-flexible suits apps that need per-key quotas in a shared store. Bottleneck suits code that paces its own outgoing calls to another API.

A token bucket refills tokens at a steady rate up to a set capacity, and each request spends one token. A full bucket allows a short burst, while an empty bucket makes requests wait or fail. limiter and @upstash/ratelimit implement token buckets.

A shared store such as Redis keeps one count for every server instance. rate-limiter-flexible and @fastify/rate-limit support Redis directly, and express-rate-limit uses a store plugin.

Bottleneck queues jobs and controls how fast and how many run at once. It can share limits across processes through Redis clustering.

A sliding window counts requests over the most recent interval rather than a fixed calendar window. @upstash/ratelimit documents window and token bucket algorithms for serverless hosts.

For coding agents

Found your rate limiting library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official