{"id":14956028,"url":"https://github.com/koffeefinance/ratelimitcop","last_synced_at":"2026-01-26T13:02:53.322Z","repository":{"id":46990160,"uuid":"407194770","full_name":"koffeefinance/ratelimitcop","owner":"koffeefinance","description":"A Redis backed rate limiter ","archived":false,"fork":false,"pushed_at":"2021-09-18T18:10:27.000Z","size":27,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-04T18:53:39.504Z","etag":null,"topics":["api","rails","rate-limiting","redis","ruby","ruby-on-rails","sidekiq"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/koffeefinance.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-16T14:23:40.000Z","updated_at":"2025-11-17T06:53:21.000Z","dependencies_parsed_at":"2022-08-25T15:12:04.472Z","dependency_job_id":null,"html_url":"https://github.com/koffeefinance/ratelimitcop","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/koffeefinance/ratelimitcop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koffeefinance%2Fratelimitcop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koffeefinance%2Fratelimitcop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koffeefinance%2Fratelimitcop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koffeefinance%2Fratelimitcop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koffeefinance","download_url":"https://codeload.github.com/koffeefinance/ratelimitcop/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koffeefinance%2Fratelimitcop/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28778729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T11:46:04.308Z","status":"ssl_error","status_checked_at":"2026-01-26T11:46:02.664Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api","rails","rate-limiting","redis","ruby","ruby-on-rails","sidekiq"],"created_at":"2024-09-24T13:12:12.315Z","updated_at":"2026-01-26T13:02:53.297Z","avatar_url":"https://github.com/koffeefinance.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ratelimitcop\n\n[![Gem Version](https://badge.fury.io/rb/ratelimitcop.svg)](https://badge.fury.io/rb/ratelimitcop) ![Build Status](https://github.com/koffeefinance/ratelimitcop/actions/workflows/ruby.yml/badge.svg)\n\nRatelimitcop is a Redis backed rate limiter. Appropriate for use cases where in-memory rate limiting would not work (i.e rate limiting across multiple processes, servers, apps, etc).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'ratelimitcop'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install ratelimitcop\n\n## Usage\n\n### Basic Usage\n\nTo rate limit calling a block of code, simply initialize `Ratelimitcop` with a `threshold` and `interval`, then pass the block of code to the `execute` method. `threshold` is the maximum number of requests that can be made within a timed `interval`, where `interval` is in seconds. `execute` will automatically block if the execution of your code block will exceed the given rate limit.\n\nNote: You need let Ratelimitcop know how it can connect to your Redis instance (or it will default to `localhost`, port 6379, as per the [Redis gem docs](https://www.rubydoc.info/gems/redis#getting-started)). To do this pass your Redis connection config as a parameter when intializing Ratelimitcop. View the [Redis gem docs](https://www.rubydoc.info/gems/redis#getting-started) to see the different ways you can connect Ratelimitcop to your Redis instance.\n\nHere is an example of an API client that uses Ratelimitcop to ensure the API's rate limits are not exceeded.\n\n```ruby\n  require `iex-ruby-client`\n  require `ratelimitcop`\n\n  class IEXCloudAPIClient\n    def initialize\n      # rate limit 100 calls per second\n      @limiter = Ratelimitcop.new(\n        name: 'iex_cloud_api',\n        threshold: 100,\n        interval: 1,\n        redis: {\n          url: ENV['REDIS_URL']\n        }\n      )\n\n      @client = IEX::Api::Client.new\n    end\n\n    def quote(ticker:)\n      # regardless of how this method is called it will block if the rate limit is exceeded before trying to run the code block\n      @limiter.execute do\n        res = @client.quote(URI.encode(ticker))\n        res\n      end\n    end\n  end\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/koffeefinance/ratelimitcop. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/koffeefinance/ratelimitcop/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Ratelimitcop project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/koffeefinance/ratelimitcop/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoffeefinance%2Fratelimitcop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoffeefinance%2Fratelimitcop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoffeefinance%2Fratelimitcop/lists"}