Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rate limiting built into FastAPI#14079

Unanswered
Edison985 asked this question inQuestions
Sep 14, 2025· 1 comments· 2 replies
Discussion options

First Check

  • I added a very descriptive title here.
  • I used the GitHub search to find a similar question and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but toPydantic.
  • I already checked if it is not related to FastAPI but toSwagger UI.
  • I already checked if it is not related to FastAPI but toReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

fromfastapiimportFastAPIfromfastapi.ratelimitimportRateLimit# Exampleapp=FastAPI()@app.get("/items",dependencies=[RateLimit(times=5,seconds=60)])asyncdefget_items():return {"message":"ok"}

Description

Currently, FastAPI does not include a rate limiting system in its core, and external libraries such as slowapi or fastapi-limiter are required.
It would be useful to discuss whether FastAPI should offer a native integration or an official/documented example for this functionality, as it is a common requirement for internet-facing APIs.

Operating System

Windows

Operating System Details

Windows 11 version 24 h2

FastAPI Version

0.116.1

Pydantic Version

2.11.9

Python Version

3.12.5

Additional Context

No response

You must be logged in to vote

Replies: 1 comment 2 replies

Comment options

@Edison985 How are you planning to include Rate Limit

Why include it as dependency, why not as a middleware?

You must be logged in to vote
2 replies
@Edison985
Comment options

@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.

@mahimairaja
Comment options

Yes, because doing it with middleware could be more reliable, as it need not trigger the router

Check this -https://github.com/laurentS/slowapi

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
questionQuestion or problem
2 participants
@Edison985@mahimairaja

[8]ページ先頭

©2009-2025 Movatter.jp