ThrottleKit is designed so the simplest path — an in-memory GCRA limiter with a synchronous fast path — takes three lines of code, and the path to a provably-bounded distributed fleet is one additional option object. This guide walks you through both.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AmeyaBorkar/throttlekit/llms.txt
Use this file to discover all available pages before exploring further.
Install the package
ThrottleKit has zero runtime dependencies. Install it with your package manager of choice:For distributed use with Redis, also install Node.js 18 or later is required.
ioredis (or node-redis):Create your first limiter
The default store is an in-process
MemoryStore. No infrastructure needed.rateLimit binds a strategy to a store and returns a Limiter. The gcra strategy stores a single timestamp per key and paces traffic smoothly — it is the recommended default.Make your first check
Every check returns an immutable You can also charge a higher cost for expensive operations:
Decision object. There are two check paths — async and sync:Handle the Decision
A Use
Decision carries everything you need to respond to the client, set headers, and schedule retries:limiter.peek(key) to read the current capacity without consuming it — useful for rendering quota dashboards:Go distributed with Redis
Switch from in-memory to Redis by providing a Each
RedisStore. The strategy, API, and Decision shape are identical — only the store changes.check call runs a single atomic EVALSHA Lua script on the Redis server — one round trip, no race conditions, no WATCH/MULTI retry loops.What’s in a Decision
Everycheck, checkSync, peek, and peekSync call returns a Decision:
Decision is a producer type — the library creates it, you read it. Per the 1.x stability contract it may grow by appending new optional readonly fields in future minor releases. Do not use zod.strict() or exhaustive property validation on a Decision.Next steps
Installation
All package manager commands, Node.js requirements, and the full list of 24 subpath entry points.
Decision
Deep dive into every field of the Decision interface, peek vs check, and forecast.
Strategies
Choose the right algorithm: GCRA, token bucket, sliding window, fixed window, and more.
Two-Tier Limiting
L1 + L2 architecture for near-zero network cost with a provable overshoot bound.