Monitoring the rate limit headers that come back on end-point GET direct_messages/events/list and trying to time my requests to minimize the delay time to the next event while staying within the limits. I have done my very best to eliminate my own errors here and I think I have. The situation is that I get the following back on GET direct_messages/events/list
11:18:12 PM $cwbot: [News Tweets] /direct: lim = 900 rem = 810 rst @ 23:19:32
using the returned headers x-rate-limit-limit:, x-rate-limit-remaining:, and x-rate-limit-reset:, respectively. I have polled 90 times (900 - 810) in 14 minutes (23:19 - 23:18 = 1 minute from next 15 minute reset interval). I should still have 810 end-point requests left. However just less than one minute later I get the rate limit exceeded response to that endpoint:
11:19:17 PM $cwbot: [News Tweets] TwitterAPIException: [blahblah] The remote server returned an error: (429) Too Many Requests.
My direct-message endpoint requests are mixed in with requests for GET statuses / home_timeline, but I am tracking the three rate-limit parameters on that end-point separately, in other words, each end-point has its own “last received” rate limit parameters from the above headers on the return from that endpoint. I have looked very carefully to see that I am not mixing things up (like the wrong reset time ha ha).
So… my question is "How is it possible that I got the 429 error when it looks like to me that I still have 810 requests left and it’s only 82 seconds away from the reset time?