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.3.0.tar.gz (36.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.3.0-py3-none-any.whl (41.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: halt_rate-0.3.0.tar.gz
  • Upload date:
  • Size: 36.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.3.0.tar.gz
Algorithm Hash digest
SHA256 e64d3078636879a7b08111acdce2f8cb3076a146eec1572d7f628f0e751f54ef
MD5 fd83a384ae636de155a5dfda100d4b03
BLAKE2b-256 a047a81b2d9e549714802e9117ce3b14e5854ab76d4e7467e2b704a92d5cb92e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: halt_rate-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 41.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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec40cea1032b2d39a87674ec8e13148400e33a80c87ceadc0b5f1d3173472103
MD5 36bfb5e52ba99ff0c70818737dd858f5
BLAKE2b-256 2ef8c75691cabdf8c71c1674f8687a74c24d0a32cee8cdefeb891649cb5816c6

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