Rate-limiter for FastAPI with the possibility of user-based rate limits
Project description
FastAPI rate limiter
This package adds a rate limiter to FastAPI using Redis.
Installation
First install Redis, then install the package using:
pip install fastapi-user-limiter
Usage
An example of how to use the rate limiter can be found in example.py
:
from fastapi_user_limiter.limiter import RateLimiter, rate_limit
from fastapi import FastAPI, Request
app = FastAPI()
rate_limiter = RateLimiter()
@app.get("/")
@rate_limit(rate_limiter, 5, 60)
async def read_root(request: Request):
return {"Hello": "World"}
Every endpoint handler with the rate limiter decorator needs to have request
(of type fastapi.Request
) as its first argument.
Future features
The package will soon have the additional feature of allowing each user account to have a different rate limit for each endpoint.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for fastapi_user_limiter-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 762159937301ce30a370a9800acfe588c1ac5757e47fe071540a013be9f1280b |
|
MD5 | 0fd9073972688292578c24d200ce8218 |
|
BLAKE2b-256 | f6319c709e02e7559cae2f76a085f65d28db27e9e107f926990a2c158badb7e5 |
Close
Hashes for fastapi_user_limiter-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98d488e03030a96cbd8322727528d7aec665a4df71fe8e71bb835788c9eb945f |
|
MD5 | a6cf65d133cbefc935f89cac846bb593 |
|
BLAKE2b-256 | 369d6498165134331f51d6c07d8f2b1436103700e100773431ed24514028237d |