{"id":13421618,"url":"https://github.com/alisaifee/flask-limiter","last_synced_at":"2025-05-12T15:26:28.991Z","repository":{"id":14052061,"uuid":"16754889","full_name":"alisaifee/flask-limiter","owner":"alisaifee","description":"Rate Limiting extension for Flask ","archived":false,"fork":false,"pushed_at":"2025-04-23T23:45:32.000Z","size":1815,"stargazers_count":1161,"open_issues_count":1,"forks_count":128,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-03T01:55:19.510Z","etag":null,"topics":["flask","memcached","python","rate-limiting","redis"],"latest_commit_sha":null,"homepage":"https://flask-limiter.readthedocs.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alisaifee.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"alisaifee","open_collective":"flask-limiter"}},"created_at":"2014-02-12T03:37:41.000Z","updated_at":"2025-05-02T05:47:34.000Z","dependencies_parsed_at":"2024-01-17T03:15:38.623Z","dependency_job_id":"62712900-2fa0-4b97-ae8a-890862672edf","html_url":"https://github.com/alisaifee/flask-limiter","commit_stats":{"total_commits":877,"total_committers":45,"mean_commits":"19.488888888888887","dds":0.1311288483466363,"last_synced_commit":"812189d8bda77d54f537b9360c9bb32998eef22b"},"previous_names":[],"tags_count":109,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisaifee%2Fflask-limiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisaifee%2Fflask-limiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisaifee%2Fflask-limiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisaifee%2Fflask-limiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alisaifee","download_url":"https://codeload.github.com/alisaifee/flask-limiter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253764788,"owners_count":21960631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","memcached","python","rate-limiting","redis"],"created_at":"2024-07-30T23:00:27.032Z","updated_at":"2025-05-12T15:26:28.959Z","avatar_url":"https://github.com/alisaifee.png","language":"Python","funding_links":["https://github.com/sponsors/alisaifee","https://opencollective.com/flask-limiter"],"categories":["Python","Python (1887)","Security","Flask Utilities","Rate Limiting","Uncategorized","介绍"],"sub_categories":["Uncategorized"],"readme":".. |ci| image:: https://github.com/alisaifee/flask-limiter/actions/workflows/main.yml/badge.svg?branch=master\n   :target: https://github.com/alisaifee/flask-limiter/actions?query=branch%3Amaster+workflow%3ACI\n.. |codecov| image:: https://codecov.io/gh/alisaifee/flask-limiter/branch/master/graph/badge.svg\n   :target: https://codecov.io/gh/alisaifee/flask-limiter\n.. |pypi| image:: https://img.shields.io/pypi/v/Flask-Limiter.svg?style=flat-square\n   :target: https://pypi.python.org/pypi/Flask-Limiter\n.. |license| image:: https://img.shields.io/pypi/l/Flask-Limiter.svg?style=flat-square\n   :target: https://pypi.python.org/pypi/Flask-Limiter\n.. |docs| image:: https://readthedocs.org/projects/flask-limiter/badge/?version=latest\n   :target: https://flask-limiter.readthedocs.org/en/latest\n\n*************\nFlask-Limiter\n*************\n\n\n|docs| |ci| |codecov| |pypi| |license|\n\n**Flask-Limiter** adds rate limiting to `Flask \u003chttps://flask.palletsprojects.com\u003e`_ applications.\n\nYou can configure rate limits at different levels such as:\n\n- Application wide global limits per user\n- Default limits per route\n- By `Blueprints \u003chttps://flask-limiter.readthedocs.io/en/latest/recipes.html#rate-limiting-all-routes-in-a-blueprint\u003e`_\n- By `Class-based views \u003chttps://flask-limiter.readthedocs.io/en/latest/recipes.html#using-flask-pluggable-views\u003e`_\n- By `individual routes \u003chttps://flask-limiter.readthedocs.io/en/latest/index.html#decorators-to-declare-rate-limits\u003e`_\n\n**Flask-Limiter** can be `configured \u003chttps://flask-limiter.readthedocs.io/en/latest/configuration.html\u003e`_ to fit your application in many ways, including:\n\n- Persistance to various commonly used `storage backends \u003chttps://flask-limiter.readthedocs.io/en/latest/#configuring-a-storage-backend\u003e`_\n  (such as Redis, Memcached \u0026 MongoDB)\n  via `limits \u003chttps://limits.readthedocs.io/en/stable/storage.html\u003e`__\n- Any rate limiting strategy supported by `limits \u003chttps://limits.readthedocs.io/en/stable/strategies.html\u003e`__\n\nFollow the quickstart below to get started or `read the documentation \u003chttp://flask-limiter.readthedocs.org/en/latest\u003e`_ for more details.\n\n\nQuickstart\n===========\n\nInstall\n-------\n.. code-block:: bash\n\n    pip install Flask-Limiter\n\nAdd the rate limiter to your flask app\n---------------------------------------\n.. code-block:: python\n\n   # app.py\n\n   from flask import Flask\n   from flask_limiter import Limiter\n   from flask_limiter.util import get_remote_address\n\n   app = Flask(__name__)\n   limiter = Limiter(\n       get_remote_address,\n       app=app,\n       default_limits=[\"2 per minute\", \"1 per second\"],\n       storage_uri=\"memory://\",\n       # Redis\n       # storage_uri=\"redis://localhost:6379\",\n       # Redis cluster\n       # storage_uri=\"redis+cluster://localhost:7000,localhost:7001,localhost:70002\",\n       # Memcached\n       # storage_uri=\"memcached://localhost:11211\",\n       # Memcached Cluster\n       # storage_uri=\"memcached://localhost:11211,localhost:11212,localhost:11213\",\n       # MongoDB\n       # storage_uri=\"mongodb://localhost:27017\",\n       strategy=\"fixed-window\", # or \"moving-window\", or \"sliding-window-counter\"\n   )\n\n   @app.route(\"/slow\")\n   @limiter.limit(\"1 per day\")\n   def slow():\n       return \"24\"\n\n   @app.route(\"/fast\")\n   def fast():\n       return \"42\"\n\n   @app.route(\"/ping\")\n   @limiter.exempt\n   def ping():\n       return 'PONG'\n\nInspect the limits using the command line interface\n---------------------------------------------------\n.. code-block:: bash\n\n   $ FLASK_APP=app:app flask limiter limits\n\n   app\n   ├── fast: /fast\n   │   ├── 2 per 1 minute\n   │   └── 1 per 1 second\n   ├── ping: /ping\n   │   └── Exempt\n   └── slow: /slow\n       └── 1 per 1 day\n\nRun the app\n-----------\n.. code-block:: bash\n\n   $ FLASK_APP=app:app flask run\n\n\nTest it out\n-----------\nThe ``fast`` endpoint respects the default rate limit while the\n``slow`` endpoint uses the decorated one. ``ping`` has no rate limit associated\nwith it.\n\n.. code-block:: bash\n\n   $ curl localhost:5000/fast\n   42\n   $ curl localhost:5000/fast\n   42\n   $ curl localhost:5000/fast\n   \u003c!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\"\u003e\n   \u003ctitle\u003e429 Too Many Requests\u003c/title\u003e\n   \u003ch1\u003eToo Many Requests\u003c/h1\u003e\n   \u003cp\u003e2 per 1 minute\u003c/p\u003e\n   $ curl localhost:5000/slow\n   24\n   $ curl localhost:5000/slow\n   \u003c!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\"\u003e\n   \u003ctitle\u003e429 Too Many Requests\u003c/title\u003e\n   \u003ch1\u003eToo Many Requests\u003c/h1\u003e\n   \u003cp\u003e1 per 1 day\u003c/p\u003e\n   $ curl localhost:5000/ping\n   PONG\n   $ curl localhost:5000/ping\n   PONG\n   $ curl localhost:5000/ping\n   PONG\n   $ curl localhost:5000/ping\n   PONG\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisaifee%2Fflask-limiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falisaifee%2Fflask-limiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisaifee%2Fflask-limiter/lists"}