If you use any background worker to make API calls, you can transfer the task, which will be performed in the next time interval, when the speed limits were reset.
class TwitterWorker include Sidekiq::Worker def perform(status_id) status = Twitter.status(status_id) # ... rescue Twitter::Error::TooManyRequests # Reschedule the query to be performed in the next time slot TwitterWorker.perform_in(15.minutes, status_id) end end
There is no scientific solution, although, for example, there is a risk that the request may be rescheduled each time if you try to make much more API calls per day than the speed limit allows. But until then, something can easily do the trick!
Thomas Klemm
source share