Thursday, August 07, 2008

APIs, and guessing what users want

I added Twitter support to Divvs yesterday. I had started it a while back, and then other things became more important, but since we’re getting Real Close to calling it “alpha” I figured I’d wrap it up.

I ran into an interesting snag with the Twitter API: it’s too clever.

I think Twitter assumes that most people using the API are writing clients of either a web or desktop variety. They also have a very strong need to limit how much data gets returned. So most of their API calls have paging, where you only get 100 records back, and have to pass in a page param to get the next set.

In our case, all I want is a list of the user’s friends and followers. I don’t need their status updates, details, pictures, or anything else.

I’d like to do something like this:

The problem is, I only get the first 100 in each call. I have to page through. Here’s what I ended up with:

This means that even for the best case, I’m doing 2 calls when 1 would suffice. Worst case, I’m doing 7, 10, 15 calls.

I’m not actually complaining about the Twitter API. They’ve optimized for their normal cases, and when I ask them about this I bet they’ll add something to turn my 15 calls into 1. (Even if they don’t, it’s not a big deal, since it works.)

It just reminds me that all too often, we assume we know what our users need. We don’t, though. They find new needs, and work around us when we get in the way.

Discussion

Follow me on Twitter. I don't have comments enabled, because I remember when we didn't have blog comments, and we did just fine, thank you very much.