{"repo":"long2ice/fastapi-limiter","free":true,"listed":false,"github":"https://github.com/long2ice/fastapi-limiter","clone":"git clone https://github.com/long2ice/fastapi-limiter.git","description":"A request rate limiter for fastapi","language":"Python","stars":791,"topics":["fastapi","limiter","asyncio"],"license":"Apache-2.0","category":"api-integrations-sdks","readme_excerpt":"fastapi-limiter Introduction FastAPI-Limiter is a rate limiting tool for fastapi routes, powered by pyrate-limiter. Install Just install from pypi Quick Start FastAPI-Limiter is simple to use, which just provides a dependency RateLimiter . The following example allows 2 requests per 5 seconds on route / . Usage RateLimiter RateLimiter accepts the following parameters: - limiter : A pyrate limiter.Limiter instance that defines the rate limiting rules. - identifier : A callable to identify the request source, default is by IP + path. - callback : A callable invoked when the rate limit is exceeded, default raises HTTPException with 429 status code. - blocking : Whether to block the request when the rate limit is exceeded, default is False . - skip : An async callable that takes a request and returns True to skip rate limiting, default is None . identifier Identifier of route limit, default is ip + path , you can override it such as userid and so on. callback Callback when rate limit is exceeded, default raises HTTPException with 429 status code. Multiple limiters You can use multiple limiters in one route. Note that you should keep the stricter limiter (lower seconds/times ratio) first. Skip rate limiting You can pass a skip callable to RateLimiter to conditionally skip rate limiting for a specific route. The callable receives the request and should return True to skip. Middleware You can also use RateLimiterMiddleware to apply rate limiting globally to all routes without adding","default_branch":null,"files":null,"tree":[],"storefront":"/r/long2ice","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/long2ice/fastapi-limiter/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}