Skip to main content

A FastAPI decorator for rate limiting requests based on specified parameters.

Project description

Installation

pip install fastapi-request-limit

Usage

Here's how you can use the request-limit decorator in a FastAPI application:~

from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from fastapi_request_limit import request_limit

app = FastAPI()

@app.post("/", response_class=JSONResponse)
@request_limit(seconds=5, data=["foo", "bar"])
async def root(foo: str, bar: int, request: Request):
    return JSONResponse(content={"message": f"Request accepted for {foo} and {bar}"})

Parameters

  • seconds (int): The number of seconds required between requests with the same parameter values.
  • data (List[str]): A list of parameter names to use for rate limiting.

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

fastapi_request_limit-0.1.4.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

fastapi_request_limit-0.1.4-py3-none-any.whl (2.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page