> ## Documentation Index
> Fetch the complete documentation index at: https://express-quota-limiter.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# express-quota-limiter: flexible quota middleware for Express

> express-quota-limiter is a driver-based quota middleware for Express.js. Enforce long-window quotas with Redis or in-memory storage, custom keys, and callbacks.

express-quota-limiter is an Express.js middleware for enforcing long-window quotas — think 500 emails per month or 1,000 API calls per day — rather than per-second rate limits. It ships with Redis and in-memory storage drivers, supports custom quota keys, request weighting, dynamic per-tenant limits, and fire-and-forget callbacks for usage tracking.

> [card] [Quick Start](https://express-quota-limiter.mintlify.site/quickstart.md)
>
> Install the package and add your first quota middleware in under five minutes.

> [card] [Core Concepts](https://express-quota-limiter.mintlify.site/concepts/quota-keys.md)
>
> Learn how quota keys, drivers, and weighting work together.

> [card] [Guides](https://express-quota-limiter.mintlify.site/guides/multi-tenant.md)
>
> Step-by-step walkthroughs for multi-tenant apps, callbacks, testing, and custom drivers.

> [card] [API Reference](https://express-quota-limiter.mintlify.site/reference/create-quota-limiter.md)
>
> Full reference for `createQuotaLimiter`, drivers, types, and response headers.

## How it works

**1. Install**

Add express-quota-limiter to your project with npm or yarn.

**2. Choose a driver**

Use `RedisDriver` for production or `MemoryDriver` for local development and tests.

**3. Create middleware**

Call `createQuotaLimiter` with your storage driver, quota key generator, and limit.

**4. Attach to routes**

Pass the returned middleware to any Express route or router.

```typescript theme={null}
import express from "express";
import { createQuotaLimiter, RedisDriver } from "express-quota-limiter";
import { redis } from "./services/redis";

const app = express();

const emailQuota = createQuotaLimiter({
  storage: new RedisDriver(redis),
  limit: 500,
  keyGenerator: (req) => `quota:emails:${req.tenantId}`,
  errorMessage: "Monthly email quota exceeded",
});

app.post("/send-email", emailQuota, (req, res) => {
  res.json({ ok: true });
});
```

> [!NOTE]
>
> Unlike rate limiters that enforce requests-per-second windows, express-quota-limiter is designed for **long-window quotas** — daily, weekly, or monthly usage caps.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.