{"id":23274022,"url":"https://github.com/iunary/fastapi-redis-rate-limiter","last_synced_at":"2025-08-25T00:31:59.999Z","repository":{"id":165007387,"uuid":"640393626","full_name":"iunary/fastapi-redis-rate-limiter","owner":"iunary","description":"fastapi-redis-rate-limiter","archived":false,"fork":false,"pushed_at":"2023-05-15T15:03:24.000Z","size":16,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-16T04:16:57.301Z","etag":null,"topics":["fastapi","python3","rate-limiter","redis"],"latest_commit_sha":null,"homepage":"","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/iunary.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2023-05-13T23:55:56.000Z","updated_at":"2024-11-24T04:55:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"ad30c061-3037-4d32-9db5-ba13e6fea308","html_url":"https://github.com/iunary/fastapi-redis-rate-limiter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iunary%2Ffastapi-redis-rate-limiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iunary%2Ffastapi-redis-rate-limiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iunary%2Ffastapi-redis-rate-limiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iunary%2Ffastapi-redis-rate-limiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iunary","download_url":"https://codeload.github.com/iunary/fastapi-redis-rate-limiter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230718572,"owners_count":18270057,"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":["fastapi","python3","rate-limiter","redis"],"created_at":"2024-12-19T20:11:31.366Z","updated_at":"2024-12-22T15:53:53.019Z","avatar_url":"https://github.com/iunary.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Fastapi rate limiter](https://github.com/iunary/fastapi-redis-rate-limiter/actions/workflows/app.yml/badge.svg)](https://github.com/iunary/fastapi-redis-rate-limiter/actions/workflows/app.yml)\n# Fastapi redis rate limiter middleware\n\nRedis Rate Limiter Middleware is a Python module that provides rate limiting functionality for FastAPI applications using Redis as the storage backend. It allows you to limit the number of requests a client can make within a specified time window.\n\n## Features\n\n- Simple integration with FastAPI applications\n- Customizable rate limit and time window\n- Uses Redis as the storage backend for efficient rate limiting\n- Easy to configure and use\n\n## Installation\n\nInstall the Redis Rate Limiter Middleware module using `pip`:\n\n```shell\npip install fastapi_redis_rate_limiter\n```\n\n## Usage\n\nHere's an example of how to use the Redis Rate Limiter Middleware in a FastAPI application:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi_redis_rate_limiter import RedisRateLimiterMiddleware, RedisClient\n\napp = FastAPI()\n\n# Initialize the Redis client\nredis_client = RedisClient(host=\"localhost\", port=6379, db=0)\n\n# Apply the rate limiter middleware to the app\napp.add_middleware(RedisRateLimiterMiddleware, redis_client=redis_client, limit=40, window=60)\n\n@app.get(\"/limited\")\nasync def limited():\n    return {\"message\": \"This is a protected endpoint.\"}\n\n\n# Run the FastAPI application\nif __name__ == \"__main__\":\n    import uvicorn\n\n    uvicorn.run(app, host=\"0.0.0.0\", port=8000)\n```\n\nIn this example, we create a FastAPI application and initialize a Redis client using `RedisClient`. Then, we add `RedisRateLimiterMiddleware` to the app middleware using `add_middleware` and by passing in Redis client, rate limit, and time window.\n\nMake sure to adjust the Redis connection parameters (host, port, and db) according to your Redis server configuration.\n\n## Configuration\n\nThe RedisRateLimiterMiddleware accepts the following parameters:\n\n- `app` (FastAPI): The FastAPI application instance.\n- `redis_client` (RedisClient): The Redis client instance for interacting with Redis.\n- `limit` (int): The maximum number of requests allowed within the time window.\n- `window` (int): The time window in seconds within which the requests are limited (default: 60 seconds).\n\nAdjust the `limit` and `window` values according to your desired rate limiting requirements.\n\n## Contributions\n\nContributions, issues, and feature requests are welcome! Feel free to open a new issue or submit a pull request on GitHub.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiunary%2Ffastapi-redis-rate-limiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiunary%2Ffastapi-redis-rate-limiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiunary%2Ffastapi-redis-rate-limiter/lists"}