SaaS-aware, cross-language rate limiting for APIs and services. One consistent model in TypeScript and Python for per-user / per-API-key / per-plan limits, quotas, weighted endpoints, abuse controls, distributed accuracy via atomic Redis, and built-in observability. Plugs into Express, Next, FastAPI, Flask, and Django.
📖 Documentation & guides: https://halt.afroawi.com/docs
| Package | Install | Registry | Installs |
|---|---|---|---|
TypeScript — packages/typescript |
npm install halt-rate |
npm | |
Python — packages/python |
pip install halt-rate |
PyPI |
- SaaS-aware, not just "requests per IP": per-user / per-API-key / per-plan limits, quotas, and weighted (cost-based) endpoints.
- Cross-language parity: the same policies, algorithms, and behavior in TS and Python.
- Distributed & accurate:
RedisStoreruns each check as a single-key Lua script, so limits stay exact under concurrency across a fleet (sync + async in Python). - Dynamic limits: change limits at runtime with a
PolicyRegistryor a cached loader (reading Redis/DB/config) — no restart. - Abuse controls: progressive penalties / abuse scoring.
- Observability built-in: zero-dep
StatsCollector(blocked counts, top limited keys, endpoint cost, plan consumption) plus an OpenTelemetry metrics adapter. - Framework adapters: Express, Next, Hono, Fastify, Flask, FastAPI, Django, GraphQL — with edge-runtime support in TypeScript.
See the per-package READMEs (TypeScript · Python) for a minimal example, and halt.afroawi.com/docs for full usage guidance.
# TypeScript
cd packages/typescript && npm install && npm test
# Python
cd packages/python && pip install -e ".[dev]" && pytestDistributed/Redis tests are opt-in via the REDIS_URL environment variable.
See CONTRIBUTING.md. Open PRs against main using conventional commits.
Licensed under MIT.