Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8k
-
First Check
Commit to Help
Example CodefromfastapiimportFastAPIfromfastapi.ratelimitimportRateLimit# Exampleapp=FastAPI()@app.get("/items",dependencies=[RateLimit(times=5,seconds=60)])asyncdefget_items():return {"message":"ok"} DescriptionCurrently, FastAPI does not include a rate limiting system in its core, and external libraries such as slowapi or fastapi-limiter are required. Operating SystemWindows Operating System DetailsWindows 11 version 24 h2 FastAPI Version0.116.1 Pydantic Version2.11.9 Python Version3.12.5 Additional ContextNo response |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment 2 replies
-
@Edison985 How are you planning to include Rate Limit Why include it as dependency, why not as a middleware? |
BetaWas this translation helpful?Give feedback.
All reactions
-
@mahimairaja If it could be done within the middleware it would be great. I say this because Express JS already has a rate limit to handle multiple requests. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Yes, because doing it with middleware could be more reliable, as it need not trigger the router Check this -https://github.com/laurentS/slowapi |
BetaWas this translation helpful?Give feedback.