## Installation
```bash
pip install fastapi-request-limit
```
### Usage
Here's how you can use the `request-limit` decorator in a FastAPI application:~
```python
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from fastapi_request_limit import request_limit
app = FastAPI()
@app.post("/", response_class=JSONResponse)
@request_limit(seconds=5, data=["foo", "bar"])
async def root(foo: str, bar: int, request: Request):
return JSONResponse(content={"message": f"Request accepted for {foo} and {bar}"})
```
### Parameters
- *seconds (int)*: The number of seconds required between requests with the same parameter values.
- *data (List[str])*: A list of parameter names to use for rate limiting.
Raw data
{
"_id": null,
"home_page": "https://github.com/sqot0/fastapi-request-limit",
"name": "fastapi-request-limit",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Sqot0",
"author_email": "kuvshinov556@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/60/b4/cdd28600f61d22a6ed80bb5199caf12c2711440a2866c0767ee523a947b4/fastapi_request_limit-0.1.4.tar.gz",
"platform": null,
"description": "\r\n## Installation\r\n\r\n```bash\r\npip install fastapi-request-limit\r\n```\r\n\r\n### Usage\r\n\r\nHere's how you can use the `request-limit` decorator in a FastAPI application:~\r\n\r\n```python\r\nfrom fastapi import FastAPI, Request\r\nfrom fastapi.responses import JSONResponse\r\nfrom fastapi_request_limit import request_limit\r\n\r\napp = FastAPI()\r\n\r\n@app.post(\"/\", response_class=JSONResponse)\r\n@request_limit(seconds=5, data=[\"foo\", \"bar\"])\r\nasync def root(foo: str, bar: int, request: Request):\r\n return JSONResponse(content={\"message\": f\"Request accepted for {foo} and {bar}\"})\r\n```\r\n\r\n### Parameters\r\n- *seconds (int)*: The number of seconds required between requests with the same parameter values.\r\n- *data (List[str])*: A list of parameter names to use for rate limiting.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A FastAPI decorator for rate limiting requests based on specified parameters.",
"version": "0.1.4",
"project_urls": {
"Homepage": "https://github.com/sqot0/fastapi-request-limit"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b6c1c3c974c12649828a958f5750daa66719beba0994b89f767faaf561c6cdd1",
"md5": "5d401ea5e4aab2a0248fe05b363bb2a8",
"sha256": "95dc84a49d93d3b040c0202459b2a528fa9e5938f3e901cd8e7a0630b16d8e19"
},
"downloads": -1,
"filename": "fastapi_request_limit-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5d401ea5e4aab2a0248fe05b363bb2a8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 2903,
"upload_time": "2024-08-01T13:47:11",
"upload_time_iso_8601": "2024-08-01T13:47:11.174305Z",
"url": "https://files.pythonhosted.org/packages/b6/c1/c3c974c12649828a958f5750daa66719beba0994b89f767faaf561c6cdd1/fastapi_request_limit-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "60b4cdd28600f61d22a6ed80bb5199caf12c2711440a2866c0767ee523a947b4",
"md5": "56b8be70968a3acfde53c1de618e6efe",
"sha256": "d8de353ab48c37ddcfe8a48833b8a98ca1953471c62e2d54e55ac18601a58a7c"
},
"downloads": -1,
"filename": "fastapi_request_limit-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "56b8be70968a3acfde53c1de618e6efe",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 2351,
"upload_time": "2024-08-01T13:47:12",
"upload_time_iso_8601": "2024-08-01T13:47:12.984264Z",
"url": "https://files.pythonhosted.org/packages/60/b4/cdd28600f61d22a6ed80bb5199caf12c2711440a2866c0767ee523a947b4/fastapi_request_limit-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-01 13:47:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sqot0",
"github_project": "fastapi-request-limit",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "fastapi-request-limit"
}