![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
fastapi-requests-limit
Advanced tools
Control and limit request rates to FastAPI applications with Redis and local memory support.
This FastAPI library enables developers to control and limit the number of requests made to API endpoints, providing an effective solution to prevent server overload and enhance security. By using Redis and local memory storage, the library keeps a record of requests per endpoint, tracking when the last request was made and the number of requests within a specific time interval. If an endpoint reaches its allowed request limit within the defined interval, the library will temporarily block further requests to that endpoint, helping to prevent API abuse. This beta version currently supports Redis and local memory as storage options, with plans to expand to more types of storage in the future.
pip install fastapi-request-limit
Explain how to use your library with simple examples. Include code blocks and descriptions for each example to guide the user. For instance:
from fastapi_requests_limit.configuration import Limiter
limiter = Limiter(host="localhost", port="6379", storage_engine='redis')
This example requires installing Redis and having a set host. If you don't want to use Redis but rather local memory, The configuration would be as follows:
from fastapi_requests_limit.configuration import Limiter
limiter = Limiter(storage_engine='memory')
Then you must limit the endpoint you want.
from fastapi_requests_limit.limiter_rest import LimiterDecorator as limiter_decorator
@app.get("/")
@limiter_decorator(time=5, count_target=3)
async def read_users(request: Request):
return [{"username": "Rick"}, {"username": "Morty"}]
limiter = Limiter(storage_engine='memory')
limiter = Limiter(host="<host>", port="<port>", storage_engine='redis')
@limiter_decorator(time=5, count_target=3)
from fastapi import FastAPI, Request
from fastapi_requests_limit.configuration import Limiter
from fastapi_requests_limit.limiter_rest import LimiterDecorator as limiter_decorator
app = FastAPI()
limiter = Limiter(host="localhost", port="6379", storage_engine='redis')
@app.get("/")
@limiter_decorator(time=5, count_target=3)
async def read_users(request: Request):
return [{"username": "Rick"}, {"username": "Morty"}]
If you're interested in contributing to this project, we welcome your contributions! Please read our CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project is licensed under the MIT License - see the LICENSE.md file for details.
FAQs
Control and limit request rates to FastAPI applications with Redis and local memory support.
We found that fastapi-requests-limit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.