We've been having problems recently with going over our rate limit when making API calls. We do a lot of server side caching of the responses we get from the API, so I was curious why we were going over our limit. I setup our application to record the headers we receive each time we make an API call, and found something interesting with X- RateLimit-Remaining:
When we make our first API call in a while a little before midnight, we get a new rate limit remaining and new expiration time. But as soon as we make a call to the API after midnight, our rate limit goes to 0, so we have to wait till the expiration time to start making calls again. Yesterday at 11:50 PM CST we made the first call to the API after our expiration time passed. Our X-RateLimit-Remaining was 149 out of 150 because that call used one of our allotted 150 per hour. The next call we made to the API was this morning at 12:10 AM CST, but our X- RateLimit-Remaining was 0. It's entirely possible that I didn't add the header tracking to another place we do API calls, but I doubt we'd have that much traffic at that time of the day to use 149 calls in 20 minutes. For the past few weeks I had it set to email me when the API returns a 400 Bad Request header. I've gotten one on the 11th at 12:17, the 10th at 12:37, the 8th at 12:22, and the 6th at 12:23 AM CST. (Google crawls our site around midnight our time, and our server side caches have expired by that time, which is the origin of most of the requests.) I found something interesting while looking through our logs for the 12th. We made an API call on the 11th at 11:35 PM, which used our 146th call per hour. The expiration time for that hour was the 12th at 12:04 AM. The next call we made was on the 12th at 12:35 AM, after our expiration date. Our rate limit remaining was back at 149 out of 150 with an expiration at 1:35 AM as expected. I was wondering if anyone has experienced something similar, or am I just missing something entirely. I can provide the headers in full if necessary.. Thanks, -Zach -- Twitter developer documentation and resources: http://dev.twitter.com/doc API updates via Twitter: http://twitter.com/twitterapi Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list Change your membership to this group: http://groups.google.com/group/twitter-development-talk
