A FastAPI rate limiting library.
Project description
Farl
A powerful and flexible FastAPI rate limiting library that provides comprehensive rate limiting capabilities for your FastAPI applications.
Features
- Easy Integration: Simple setup with FastAPI applications
- Flexible Configuration: Support for various rate limiting strategies
- Multiple Backends: In-memory and Redis backend support
- Comprehensive Protection: Request rate limiting with customizable rules
- Monitoring: Built-in metrics and logging capabilities
- Dependency Injection: FastAPI-style dependency injection support
Installation
pip install farl
Optional Dependencies
For Redis backend support:
pip install farl[redis]
For development:
pip install farl[dev,tests]
Quick Start
from fastapi import Depends, FastAPI
from pydantic import RedisDsn
from farl import (
AsyncFarl,
FarlError,
farl_exceptions_handler,
rate_limit,
)
# Using Redis backend
redis_uri = RedisDsn("redis://") # or "redis://"
farl = AsyncFarl(redis_uri=redis_uri)
app = FastAPI()
app.add_exception_handler(FarlError, farl_exceptions_handler)
@app.get(
"/",
dependencies=[
Depends(
rate_limit({"amount": 1}),
)
],
)
async def pre_minute_1_request():
return {"message": "ok"}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
farl-0.0.4.tar.gz
(40.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
farl-0.0.4-py3-none-any.whl
(11.7 kB
view details)
File details
Details for the file farl-0.0.4.tar.gz.
File metadata
- Download URL: farl-0.0.4.tar.gz
- Upload date:
- Size: 40.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbea26b69f02e344687aa88a788f7ba4720b5745301f25f960ce85d69b4d9e03
|
|
| MD5 |
222eb364e74fe774c273d196433d3da8
|
|
| BLAKE2b-256 |
74b2f2328b305fc1ae0b850cf13639f5c5bd91b2e51ea1005f23f52a00649c87
|
File details
Details for the file farl-0.0.4-py3-none-any.whl.
File metadata
- Download URL: farl-0.0.4-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c081abe3461de609dd148fafe4ca3911ff2108352bf9b195f197e9a811d9ab6
|
|
| MD5 |
3fe9c6918ed45fae331b8cb7163c4b6d
|
|
| BLAKE2b-256 |
3cb768fea9544268a49efd85bf1ccc14f4e736bd7cbfa4f8afa073edb2f52cec
|