ruby on rails - Dealing with API rate limits? -


i've app that's set make scheduled calls number of apis once day. works nicely i'm aware of apis i'm calling (twitter example) have rate limit. number of calls i'm making set continually grow, can recommend way throttle calls can send in bursts of x per hour/minute etc?

i've found glutton ratelimit gem, using , good? there others should looking at?

if you're using kind of background worker perform api calls, reschedule task reperformed in next time slot, when rate limits have been reset.

class twitterworker   include sidekiq::worker    def perform(status_id)     status = twitter.status(status_id)     # ...    rescue twitter::error::toomanyrequests     # reschedule query performed in next time slot     twitterworker.perform_in(15.minutes, status_id)   end end 

no scientific solution though, there's e.g. risk query might rescheduled each time if try perform more api calls in day rate limit allows for. until then, easy might trick!


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -