{"id":23279,"library":"asgi-ratelimit","title":"asgi-ratelimit","description":"ASGI middleware for rate limiting requests using a token bucket algorithm. Current version 0.10.0, requires Python >=3.6,<4.0. Release cadence is irregular.","status":"active","version":"0.10.0","language":"python","source_language":"en","source_url":"https://github.com/abersheeran/asgi-ratelimit","tags":["asgi","rate-limiting","middleware","token-bucket"],"install":[{"cmd":"pip install asgi-ratelimit","lang":"bash","label":"default"}],"dependencies":[],"imports":[{"note":"Correct import path for the middleware class.","symbol":"RateLimitMiddleware","correct":"from asgi_ratelimit import RateLimitMiddleware"},{"note":"Decorator or helper for rate limiting.","symbol":"RateLimit","correct":"from asgi_ratelimit import RateLimit"}],"quickstart":{"code":"from asgi_ratelimit import RateLimitMiddleware, RateLimit\n\napp = RateLimitMiddleware(\n    some_asgi_app,\n    auth_func=lambda scope: scope[\"client\"][0],\n    limiter=RateLimit(10, 60)  # 10 requests per 60 seconds\n)","lang":"python","description":"Basic rate limiting middleware wrapping an ASGI app."},"warnings":[{"fix":"Ensure auth_func returns a string, e.g., lambda scope: scope['client'][0].","message":"The `auth_func` must return a hashable string (e.g., IP, user ID). Returning a tuple or non-hashable will cause a runtime TypeError.","severity":"gotcha","affected_versions":"all"},{"fix":"For distributed apps, pass a Redis backend: from asgi_ratelimit import RedisBackend; RateLimitMiddleware(..., backend=RedisBackend('redis://localhost')).","message":"Rate limiter backends (Redis, memory) must be configured explicitly; default is in-memory dictionary (not shared across processes).","severity":"gotcha","affected_versions":"all"},{"fix":"Use correct top-level import: `from asgi_ratelimit import RedisBackend` or check version for exact path.","message":"The `backend` parameter in v0.9+ changed; the old direct class import `from asgi_ratelimit.backends import RedisBackend` may break if using newer structuring.","severity":"deprecated","affected_versions":">=0.9.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change auth_func to return a string, e.g., lambda scope: scope['client'][0]","cause":"auth_func returns a list/tuple instead of a hashable string.","error":"TypeError: unhashable type: 'list'"},{"fix":"Import backend from the main module: from asgi_ratelimit import RedisBackend","cause":"In v0.9+ backends may have moved to top-level package.","error":"ModuleNotFoundError: No module named 'asgi_ratelimit.backends'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}