{"id":23421497,"url":"https://github.com/domaintools/rate-limit","last_synced_at":"2025-04-12T14:06:15.830Z","repository":{"id":141937278,"uuid":"9302432","full_name":"DomainTools/rate-limit","owner":"DomainTools","description":"Implementation of a Redis rate limiter in Python","archived":false,"fork":false,"pushed_at":"2013-05-16T19:32:19.000Z","size":208,"stargazers_count":78,"open_issues_count":0,"forks_count":12,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-03-26T08:37:32.037Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/DomainTools.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}},"created_at":"2013-04-08T17:31:35.000Z","updated_at":"2025-03-25T14:04:51.000Z","dependencies_parsed_at":"2023-03-12T10:51:41.382Z","dependency_job_id":null,"html_url":"https://github.com/DomainTools/rate-limit","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/DomainTools%2Frate-limit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DomainTools%2Frate-limit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DomainTools%2Frate-limit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DomainTools%2Frate-limit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DomainTools","download_url":"https://codeload.github.com/DomainTools/rate-limit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248578864,"owners_count":21127713,"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":[],"created_at":"2024-12-23T02:15:32.171Z","updated_at":"2025-04-12T14:06:15.789Z","avatar_url":"https://github.com/DomainTools.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"rate-limit\n==========\n\nImplementation of a Redis rate limiter in Python\n\n## class __RateLimiter__\n****************************************\nRateLimiter is used to define one or more rate limit rules.\nThese rules are checked on .acquire() and we either return True or False based on if we can make the request,\nor we can block until we make the request.\nManual blocks are also supported with the block method.\n\n\n### __methods__\n****************************************\n\n#### def \\__init\\__(self, conditions=None, redis_host='localhost', redis_port=6379, redis_db=0, redis_password=None, redis_namespace='ratelimiter'):\n\nInitalize an instance of a RateLimiter\n\n    conditions - list or tuple of rate limit rules\n    redis_host - Redis host to use\n    redis_port - Redis port (if different than default 6379)\n    redis_db   - Redis DB to use (if different than 0)\n    redis_password - Redis password (if needed)\n    redis_namespace - Redis key namespace\n\n#### def __acquire__(self, key, block=True):\n\nTests whether we can make a request, or if we are currently being limited\n\n    key - key to track what to rate limit\n    block - Whether to wait until we can make the request\n\n#### def __add_condition__(self, *conditions):\n\nAdds one or more conditions to this RateLimiter instance\nConditions can be given as:\n\n    add_condition(1, 10)\n    add_condition((1, 10))\n    add_condition((1, 10), (30, 600))\n    add_condition({'requests': 1, 'seconds': 10})\n    add_condition({'requests': 1, 'seconds': 10}, {'requests': 200, 'hours': 6})\n\n    dict can contain 'seconds', 'minutes', 'hours', and 'days' time period parameters\n\n#### def __block__(self, key, seconds=0, minutes=0, hours=0, days=0):\n\nSet manual block for key for a period of time\n\n    key - key to track what to rate limit\n    Time parameters are added together and is the period to block for\n    seconds\n    minutes\n    hours\n    days\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomaintools%2Frate-limit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdomaintools%2Frate-limit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomaintools%2Frate-limit/lists"}