Pushing the limit

Regularly, twhirl users report that the program runs into a “limit exceeded” error and pauses for five minutes before trying to get new updates from Twitter again. Most of the time, they blame it on twhirl, and I always have to explain that it’s not its fault. This article will take a detailed view on what “the limit” is, why you may run into it, and ways to avoid it.

What’s this limit stuff all about?

Let’s start with an introduction in what the request limit is at all. Twitter mainly is a website that is intended to be used via a web browser, an instant messaging client or SMS. Using these three access points, you are free to fetch information or interact with the service as often as you like, there is no limit imposed.
But Twitter offers another way to use their service: the Twitter API (Application Programming Interface). This is the way all desktop clients, third-party-webservices or browser extensions work. They send requests to the API and get an answer from the Twitter servers, like fetching a user’s tweets, posting a status update, setting a favorite, requesting a user’s profile information etc. Some of these requests can be done without sending a username and password, like requesting the public timeline, but most require the client to send a valid username and password with the request.
Using the Twitter API is free, but the number of requests you may send is limited to 70 per hour. Starting from the first request, within the next 60 minutes the API may not be accessed more than 70 times, otherwise access to the API will be locked until the 60 minutes are elapsed and the next period starts.

Which requests are counted among the limit?

There are some requests that don’t increase your count. You can write an unlimited number of tweets and direct messages per hour, and requesting the public timeline is free, too. All other requests will increase the counter, like fetching replies, fetching your archived tweets, following a user, deleting a direct message and so on.
Twitter counts all requests to the API using your username and password, independent from where they come. So if you are running two clients at the same time, they will share the same counter.

What does twhirl do to avoid hitting the limit?

Like most Twitter desktop clients, twhirl asks the Twitter API regularly if there are new tweets, replies or direct messages for you. It has a built-in mechanism that will prevent these automatic requests to exceed the limit within the 60 minute period. It’s up to you how many requests it is allowed to use for this purpose, from 10 to 60 per hour. By default, it will use 40 requests per hour, leaving about 30 for you.
What twhirl cannot control is how often the user (you) triggers a request, for example by deleting tweets, making them favorites or looking up a user profile (which actually consumes two requests, one for requesting the profile information, another for fetching his tweets).
If twhirl tries to access the API, but the limit is exceeded, Twitter returns an error. Twhirl understands this, informs you about it and pauses automatic requests for five minutes. Why five minutes? Under normal conditions, the limit will be exceeded to the end of the 60 minutes. Waiting five minutes might get you out of the period and you have 70 fresh requests. Twhirl will issue one request after the five minute wait to see if you are unlocked again, and pause another five minutes if not (and so on). If Twitter has unlocked your account, it will resume normal automatic requests.

Why does my twhirl say I exceeded the limit?

There are several reasons why this could happen. Most of the time, one or a combination of the following scenarios could lead to exceeding the limit:
  • You clicked the buttons too often
    Yes, I know, buttons exist to be clicked. But keep in mind that many of twhirl’s buttons trigger some interaction with the Twitter API. For example, if you go through a list of old direct messages you received and delete twenty of them, every single delete will use a request.
  • Another API client talks to Twitter using your credentials
    You have another client running that uses your username and password to send requests to the Twitter API. This can be a browser extension like TwitterFox, a social browser like Flock which rembers your account and frequently checks for your friends’ updates, or maybe even a third-party web service.
  • You (re)started twhirl multiple times within a short period of time
    The built-in limit protection can only work reliably if you let twhirl run for a longer time. If you restart it over and over, requests may be issued in shorter time spans than it should.
  • You are at work, and left twhirl running on your home computer
    Right, a special case of the second scenario, but don’t laugh, it already happend to people…
You see, API requests are of great value in the Twitterverse. Always keep that in mind, and don’t waste them carelessly.

What else can I do?

A simple way to decrease the number of requests you consume is to decrease the twhirl’s automatic request usage. But this can lead to other problems like missing tweets, because twhirl cannot keep up with your friends’ postings.
Do not use twhirl’s built-in profile lookup too often, as it requires two requests! Configure twhirl to open the user’s profile on twitter.com in a browser instead when you click on a username.
Basically, if you do not run other API clients, there is nothing more you can do, unfortunately. It’s normally not a big problem if you hit the limit infrequently. But if it happens more often, you may have to rethink how you use twhirl (or any other Twitter client, as all the above is true for every one of them).

Conclusion

Hopefully, this introduction helped you to understand what the limit is, how it works, why you hit it (if you hit it), and what you an do against it. If anything is unclear or missing, add a comment and I’ll try to clarify it.