Skip to main content

Halt — Python SDK

SaaS-aware, cross-language rate limiting. Per-user / per-API-key / per-plan limits, quotas, weighted endpoints, abuse controls, atomic Redis accuracy (sync + async), and built-in observability — with a matching TypeScript package.

PyPI License: MIT

📖 Full documentation: halt.afroawi.com

Install

pip install halt-rate
# optional extras
pip install "halt-rate[redis]"    # production store (sync + async)
pip install "halt-rate[fastapi]"  # framework adapter
pip install "halt-rate[otel]"     # OpenTelemetry metrics

Installs as halt-rate; import as halt.

Quick start

from halt import RateLimiter, InMemoryStore, presets

limiter = RateLimiter(
    store=InMemoryStore(),      # use RedisStore in production
    policy=presets.PUBLIC_API,  # 100 req/min per IP
)

decision = limiter.check(request)   # or: await limiter.acheck(request)
if not decision.allowed:
    # respond 429, Retry-After: decision.retry_after
    ...

Production Redis (sync + async), FastAPI/Flask/Django adapters, plan-based limits, quotas, penalties, and observability are covered in the docs → halt.afroawi.com/docs.

Features

  • Algorithms: token bucket, fixed/sliding window, leaky bucket
  • Keys: IP, user, API key, composite, or custom
  • Atomic Redis store (Lua, cluster-safe, fail-open), sync and async, + in-memory dev store
  • SaaS: per-plan limits, quotas, weighted endpoints, abuse penalties
  • Observability: StatsCollector + OpenTelemetry metrics
  • Adapters: FastAPI, Flask, Django

Links

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

halt_rate-0.5.0.tar.gz (46.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

halt_rate-0.5.0-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

File details

Details for the file halt_rate-0.5.0.tar.gz.

File metadata

  • Download URL: halt_rate-0.5.0.tar.gz
  • Upload date:
  • Size: 46.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for halt_rate-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d8eaff3fd0be8379c818792955b52ec8317a1381f4cee6aa581e130366e3f2be
MD5 26193f4095c0d257a2bb173350c86624
BLAKE2b-256 a90795ebf841b60dc0c6d32ee1c9f119bb4490d224c5fec7839b3a49cfecefb0

See more details on using hashes here.

File details

Details for the file halt_rate-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: halt_rate-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 43.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for halt_rate-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 891e4c4ad9069d57307145e8be9d12c99ad42f4f91b43d05ddfec5b0f92e0857
MD5 f728100bcc8a0f32c19b52383933a166
BLAKE2b-256 facdf7f36590da855cf03a8325d6f8fbf19f45cfeaf62aab82c97956316b1d42

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page