Skip to content

A Python package for FastAPI that provides a decorator to limit the rate of requests based on specified parameters

License

Notifications You must be signed in to change notification settings

sqot0/fastapi-request-limit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Request Limit

A Python package for FastAPI that provides a decorator to limit the rate of requests based on specified parameters.

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.

About

A Python package for FastAPI that provides a decorator to limit the rate of requests based on specified parameters

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages