Skip to main content

A FastAPI rate limiting library.

Project description

Farl

Python 3.11+ PyPI version Coverage Status Code Coverage License

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 farl import (
    AsyncFarl,
    FarlError,
    farl_exceptions_handler,
    rate_limit,
)


# Using Redis backend
farl = AsyncFarl()

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.5.tar.gz (40.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

farl-0.0.5-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file farl-0.0.5.tar.gz.

File metadata

  • Download URL: farl-0.0.5.tar.gz
  • Upload date:
  • Size: 40.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.15

File hashes

Hashes for farl-0.0.5.tar.gz
Algorithm Hash digest
SHA256 44572ea7e035d024dd51aa2a6d364a41c5b2b8e4ff2dee1de276bbfdcec54394
MD5 2f28738b52f7f2fb16cf8cc2d0464656
BLAKE2b-256 5975e29e8fd6dc0c554e6d394084d12e1b9ec3506bd4673d5fd3843f7fabfba5

See more details on using hashes here.

File details

Details for the file farl-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: farl-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.15

File hashes

Hashes for farl-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d66b1e016c4908f8e1c397fde98631ac711cb3e69387590a3db9dd74a2994ac4
MD5 0e4e4511339adf011b5b3c0e33b91147
BLAKE2b-256 d3de06bd4c50304213f5a210f662f550ea83a45cdd23dc8074075d0f2ad31574

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 Pingdom Monitoring Sentry Error logging StatusPage Status page