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.4.0.tar.gz (38.8 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.4.0-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: halt_rate-0.4.0.tar.gz
  • Upload date:
  • Size: 38.8 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.4.0.tar.gz
Algorithm Hash digest
SHA256 25303ef1282f8563b550023ae5dbd66a3382f172da3cda85d8f73cbb8335658a
MD5 86efa5a42f1113fa3f76a50cdd768997
BLAKE2b-256 102a05b6b2815c5571ce751a8398029eae59b5cdbe790523c771ecdcfa3f810e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: halt_rate-0.4.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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2379d5ac9d907fba77b75e54d7be334fdc7ee2c79be406346cbd06eed6b3c687
MD5 58a3fb03ee066b5295cc1c4bf05d1f15
BLAKE2b-256 7ead69e879632a066fd72473e94561b6e9a1b803818fc45bd7e2166e22b15394

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