{"id":21347714,"url":"https://github.com/jgltechnologies/aiohttp-ratelimiter","last_synced_at":"2025-08-25T20:07:38.239Z","repository":{"id":48129769,"uuid":"442662915","full_name":"JGLTechnologies/aiohttp-ratelimiter","owner":"JGLTechnologies","description":"A rate limiter for the aiohttp.web framework","archived":false,"fork":false,"pushed_at":"2025-05-14T03:27:18.000Z","size":2888,"stargazers_count":14,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-22T04:47:53.956Z","etag":null,"topics":["aiohttp","api","asyncio","python","rate-limiter","rate-limiting","ratelimit"],"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/JGLTechnologies.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,"zenodo":null}},"created_at":"2021-12-29T04:50:33.000Z","updated_at":"2025-05-11T22:47:30.000Z","dependencies_parsed_at":"2025-05-09T14:56:02.033Z","dependency_job_id":"bdde9911-1123-4d08-83b5-90d4c7820c76","html_url":"https://github.com/JGLTechnologies/aiohttp-ratelimiter","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/JGLTechnologies/aiohttp-ratelimiter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JGLTechnologies%2Faiohttp-ratelimiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JGLTechnologies%2Faiohttp-ratelimiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JGLTechnologies%2Faiohttp-ratelimiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JGLTechnologies%2Faiohttp-ratelimiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JGLTechnologies","download_url":"https://codeload.github.com/JGLTechnologies/aiohttp-ratelimiter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JGLTechnologies%2Faiohttp-ratelimiter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272124753,"owners_count":24877720,"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","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aiohttp","api","asyncio","python","rate-limiter","rate-limiting","ratelimit"],"created_at":"2024-11-22T02:15:49.629Z","updated_at":"2025-08-25T20:07:38.215Z","avatar_url":"https://github.com/JGLTechnologies.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://jgltechnologies.com/discord\"\u003e\n\u003cimg src=\"https://discord.com/api/guilds/844418702430175272/embed.png\"\u003e\n\u003c/a\u003e\n\n# aiohttp-ratelimiter\n\naiohttp-ratelimiter is a rate limiter for the aiohttp.web framework.\nThis is a new library, and we are always looking for people to contribute. If you see something wrong with the code or want to add a feature, please create a pull request \non \u003ca href=\"https://jgltechnologies.com/aiohttplimiter\"\u003eour github\u003c/a\u003e.\n\n\nInstall from git\n```\npython -m pip install git+https://github.com/JGLTechnologies/aiohttp-ratelimiter\n```\n\nInstall from pypi\n```\npython -m pip install aiohttp-ratelimiter\n// if redis is being used\npython -m pip install aiohttp-ratelimiter[redis]\n// if memcached is being used\npython -m pip install aiohttp-ratelimiter[memcached]\n```\n\n\u003cbr\u003e\n\n\nExample\n\n```python\nfrom aiohttp import web\nfrom aiohttplimiter import default_keyfunc, Limiter\nfrom aiohttplimiter.redis_limiter import RedisLimiter\nfrom aiohttplimiter.memcached_limiter import MemcachedLimiter\n\napp = web.Application()\nroutes = web.RouteTableDef()\n\n# In Memory\nlimiter = Limiter(keyfunc=default_keyfunc)\n# Redis\nlimiter = RedisLimiter(keyfunc=default_keyfunc, uri=\"redis://localhost:6379\")\n# Memcached\nlimiter = MemcachedLimiter(keyfunc=default_keyfunc, uri=\"memcached://localhost:11211\")\n\n@routes.get(\"/\")\n# This endpoint can only be requested 1 time per second per IP address\n@limiter.limit(\"1/second\")\nasync def home(request):\n    return web.Response(text=\"test\")\n\napp.add_routes(routes)\nweb.run_app(app)\n```\n\n\u003cbr\u003e\n\nYou can exempt an IP from rate limiting using the exempt_ips kwarg.\n\n```python\nfrom aiohttplimiter import Limiter, default_keyfunc\nfrom aiohttp import web\n\napp = web.Application()\nroutes = web.RouteTableDef()\n\n# 192.168.1.245 is exempt from rate limiting.\n# Keep in mind that exempt_ips takes a set not a list.\nlimiter = Limiter(keyfunc=default_keyfunc, exempt_ips={\"192.168.1.245\"})\n\n@routes.get(\"/\")\n@limiter.limit(\"3/5minutes\")\nasync def test(request):\n    return web.Response(text=\"test\")\n\napp.add_routes(routes)\nweb.run_app(app)\n```\n\n\u003cbr\u003e\n\nYou can create your own error handler by using the error_handler kwarg.\n\n```python\nfrom aiohttplimiter import Allow, RateLimitExceeded, Limiter, default_keyfunc\nfrom aiohttp import web\n\ndef handler(request: web.Request, exc: RateLimitExceeded):\n    # If for some reason you want to allow the request, return aiohttplimitertest.Allow().\n    if some_condition:\n        return Allow()\n    return web.Response(text=f\"Too many requests\", status=429)\n\nlimiter = Limiter(keyfunc=default_keyfunc, error_handler=handler)\n```\n\n\u003cbr\u003e\n\nIf multiple paths use one handler like this:\n```python\n@routes.get(\"/\")\n@routes.get(\"/home\")\n@limiter.limit(\"5/hour\")\ndef home(request):\n    return web.Response(text=\"Hello\")\n```\n\n\u003cbr\u003e\n\nThen they will have separate rate limits. To prevent this use the path_id kwarg.\n\n```python\n@routes.get(\"/\")\n@routes.get(\"/home\")\n@limiter.limit(\"2/3days\", path_id=\"home\")\ndef home(request):\n    return web.Response(text=\"Hello\")\n```\n\n\u003cbr\u003e\n\nViews Example \n\n```python\n@routes.view(\"/\")\nclass Home(View):\n    @limiter.limit(\"1/second\")\n    def get(self):\n        return web.Response(text=\"hello\")\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgltechnologies%2Faiohttp-ratelimiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgltechnologies%2Faiohttp-ratelimiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgltechnologies%2Faiohttp-ratelimiter/lists"}