# SlowApi
A rate limiting library for Starlette and FastAPI adapted from [flask-limiter](http://github.com/alisaifee/flask-limiter).
This package is used in various production setups, handling millions of requests per month, and seems to behave as expected.
There might be some API changes when changing the code to be fully `async`, but we will notify users via appropriate `semver` version changes.
The documentation is on [read the docs](https://slowapi.readthedocs.io/en/latest/).
# Quick start
## Installation
`slowapi` is available from [pypi](https://pypi.org/project/slowapi/) so you can install it as usual:
```
$ pip install slowapi
```
# Features
Most feature are coming from FlaskLimiter and the underlying [limits](https://limits.readthedocs.io/).
Supported now:
- Single and multiple `limit` decorator on endpoint functions to apply limits
- redis, memcached and memory backends to track your limits (memory as a fallback)
- support for sync and async HTTP endpoints
- Support for shared limits across a set of routes
# Limitations and known issues
* The `request` argument must be explicitly passed to your endpoint, or `slowapi` won't be able to hook into it. In other words, write:
```python
@limiter.limit("5/minute")
async def myendpoint(request: Request)
pass
```
and not:
```python
@limiter.limit("5/minute")
async def myendpoint()
pass
```
* `websocket` endpoints are not supported yet.
# Developing and contributing
PRs are more than welcome! Please include tests for your changes :)
The package uses [poetry](https://python-poetry.org) to manage dependencies. To setup your dev env:
```bash
$ poetry install
```
To run the tests:
```bash
$ pytest
```
# Credits
Credits go to [flask-limiter](https://github.com/alisaifee/flask-limiter) of which SlowApi is a (still partial) adaptation to Starlette and FastAPI.
It's also important to mention that the actual rate limiting work is done by [limits](https://github.com/alisaifee/limits/), `slowapi` is just a wrapper around it.
Raw data
{
"_id": null,
"home_page": "https://github.com/laurents/slowapi",
"name": "slowapi",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Laurent Savaete",
"author_email": "laurent@where.tf",
"download_url": "https://files.pythonhosted.org/packages/a0/99/adfc7f94ca024736f061257d39118e1542bade7a52e86415a4c4ae92d8ff/slowapi-0.1.9.tar.gz",
"platform": null,
"description": "# SlowApi\n\nA rate limiting library for Starlette and FastAPI adapted from [flask-limiter](http://github.com/alisaifee/flask-limiter).\n\nThis package is used in various production setups, handling millions of requests per month, and seems to behave as expected.\nThere might be some API changes when changing the code to be fully `async`, but we will notify users via appropriate `semver` version changes.\n\nThe documentation is on [read the docs](https://slowapi.readthedocs.io/en/latest/).\n\n# Quick start\n\n## Installation\n\n`slowapi` is available from [pypi](https://pypi.org/project/slowapi/) so you can install it as usual:\n\n```\n$ pip install slowapi\n```\n\n# Features\n\nMost feature are coming from FlaskLimiter and the underlying [limits](https://limits.readthedocs.io/).\n\nSupported now:\n\n- Single and multiple `limit` decorator on endpoint functions to apply limits\n- redis, memcached and memory backends to track your limits (memory as a fallback)\n- support for sync and async HTTP endpoints\n- Support for shared limits across a set of routes\n\n\n# Limitations and known issues\n\n * The `request` argument must be explicitly passed to your endpoint, or `slowapi` won't be able to hook into it. In other words, write:\n\n```python\n @limiter.limit(\"5/minute\")\n async def myendpoint(request: Request)\n pass\n```\n\nand not:\n\n```python\n @limiter.limit(\"5/minute\")\n async def myendpoint()\n pass\n```\n\n * `websocket` endpoints are not supported yet.\n\n# Developing and contributing\n\nPRs are more than welcome! Please include tests for your changes :)\n\nThe package uses [poetry](https://python-poetry.org) to manage dependencies. To setup your dev env:\n\n```bash\n$ poetry install\n```\n\nTo run the tests:\n```bash\n$ pytest\n```\n\n# Credits\n\nCredits go to [flask-limiter](https://github.com/alisaifee/flask-limiter) of which SlowApi is a (still partial) adaptation to Starlette and FastAPI.\nIt's also important to mention that the actual rate limiting work is done by [limits](https://github.com/alisaifee/limits/), `slowapi` is just a wrapper around it.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A rate limiting extension for Starlette and Fastapi",
"version": "0.1.9",
"project_urls": {
"Documentation": "https://slowapi.readthedocs.io/en/latest/",
"Homepage": "https://github.com/laurents/slowapi",
"Repository": "https://github.com/laurents/slowapi"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2bbbf71c4b7d7e7eb3fc1e8c0458a8979b912f40b58002b9fbf37729b8cb464b",
"md5": "ce24d08cec75be692f8f7ebb624a9a24",
"sha256": "cfad116cfb84ad9d763ee155c1e5c5cbf00b0d47399a769b227865f5df576e36"
},
"downloads": -1,
"filename": "slowapi-0.1.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ce24d08cec75be692f8f7ebb624a9a24",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 14670,
"upload_time": "2024-02-05T12:11:50",
"upload_time_iso_8601": "2024-02-05T12:11:50.898492Z",
"url": "https://files.pythonhosted.org/packages/2b/bb/f71c4b7d7e7eb3fc1e8c0458a8979b912f40b58002b9fbf37729b8cb464b/slowapi-0.1.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a099adfc7f94ca024736f061257d39118e1542bade7a52e86415a4c4ae92d8ff",
"md5": "726be5caae0edc822299b16099894e0f",
"sha256": "639192d0f1ca01b1c6d95bf6c71d794c3a9ee189855337b4821f7f457dddad77"
},
"downloads": -1,
"filename": "slowapi-0.1.9.tar.gz",
"has_sig": false,
"md5_digest": "726be5caae0edc822299b16099894e0f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 14028,
"upload_time": "2024-02-05T12:11:52",
"upload_time_iso_8601": "2024-02-05T12:11:52.130621Z",
"url": "https://files.pythonhosted.org/packages/a0/99/adfc7f94ca024736f061257d39118e1542bade7a52e86415a4c4ae92d8ff/slowapi-0.1.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-05 12:11:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "laurents",
"github_project": "slowapi",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "slowapi"
}