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

Uploaded Python 3

File details

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

File metadata

  • Download URL: farl-0.0.7.tar.gz
  • Upload date:
  • Size: 47.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for farl-0.0.7.tar.gz
Algorithm Hash digest
SHA256 cb30e9a62bfeb2e125f6b08a0fe889d3e3c0b1c8244a2b09d33ef519b279633e
MD5 326b25d562d216e1a9bca92e5cdbd8bf
BLAKE2b-256 d47de783a41ac6b6062f22c4aeafe7c57a28daa3a3eeb0ebc61972c6f77fde74

See more details on using hashes here.

Provenance

The following attestation bundles were made for farl-0.0.7.tar.gz:

Publisher: ci.yml on nafnix/farl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: farl-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for farl-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b15c5d2fbb7fdaf744f4664bc92f16ebf0deb29d18cfc9df6a763ad020219110
MD5 a13ccd70355721b1cb960e9a2877351c
BLAKE2b-256 48040e5c80d4d26a848473e8ae4b2dd570a488b1ec276680e93e0fe0aafef3d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for farl-0.0.7-py3-none-any.whl:

Publisher: ci.yml on nafnix/farl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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