Quick Twitter API Tip: Don’t Make Requests on The Hour

March 12, 2011

Data from the Twitter API

The title says it all, really.

I’m currently running two almost-identical scripts that pull data from the Twitter API every half an hour. The first version of the script runs at :00 and :30 minutes past every hour, and the second version at :05 and :35 minutes past every hour.

The on-the-hour/half-hour script fails (i.e. the API doesn’t respond) about two to three times more often than the 5 minute delayed version. Failed API calls can be identified in the sample screenshot above by 0 values – none of the calls should return a zero value.

So that’s it, really. The most likely reason is that :00 and :30 are peak times for API requests, so you’re more likely to make a request at these times to an overloaded API service. Shift your calls around a bit in the hour, and you’ll get a more robust response. This probably holds true for other APIs too.

Tags: , , ,

Leave a Reply