https://github.com/stupidcodefactory/rate_limited_api
limits your api calls before hitting the critical point
https://github.com/stupidcodefactory/rate_limited_api
Last synced: 6 months ago
JSON representation
limits your api calls before hitting the critical point
- Host: GitHub
- URL: https://github.com/stupidcodefactory/rate_limited_api
- Owner: StupidCodeFactory
- License: mit
- Created: 2013-11-26T13:40:00.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-01-19T14:30:11.000Z (over 11 years ago)
- Last Synced: 2024-12-29T22:42:31.787Z (over 1 year ago)
- Language: Ruby
- Size: 250 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://travis-ci.org/StupidCodeFactory/rate_limited_api)
](https://gemnasium.com/StupidCodeFactory/rate_limited_api)
#### RateLimitedApi ####
This library aims at managing rate limitation of APIs accross multiple
server/application
It currently depends on redis
## Installation
```shell
gem 'rate_limited_api', github: 'StupidCodeFactory/rate_limited_api'
```
And then execute:
$ bundle
## Usage
### configuration
```ruby
RateLimitedApi.configure do |config|
config.redis = "redis://redis.example.com:666"
end
```
### use with any object
```ruby
rate_limiter = RateLimitedApi::Limiter.new :facebook, 150, :day
graph = Koala::Facebook::API.new(oauth_access_token)
facebook = RateLimitedApi::Api.new(graph, [:get_object, :get_connections], rate_limiter)
100.times { facebook.get_object('me') } # => '{'id': 123123234}'
50.times { facebook.get_connections('me', 'friends') } # => '{'friends': [{'id': 4564564}]}'
facebook.get_object('me') # ooops raises RateLimitedApi::RateLimitReached !
```
### Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request