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]

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.6.tar.gz (40.5 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.6-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for farl-0.0.6.tar.gz
Algorithm Hash digest
SHA256 37f2a526d8fe1f65445aaf10cfb5f1cb6508e88f1e6852ec5e51d4c98291caf4
MD5 71dedf36af8e6f3e206ddf4a8dcb01d7
BLAKE2b-256 8c85caa3c010d3c0ba0e869e50b48f4ff17edb7a9c7b48b28562e22e46a76cdb

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for farl-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 132a71ec3308d5d83fa121c18ad0b34ed71f8b22be6455d5f265d813ceccfead
MD5 c1b4d96a0006ce1ffb84f751a4d31994
BLAKE2b-256 be40ce29aa63d3b7f256cb8065d8da7732e7eb81a48d0cd84aa4df62f18a07ab

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