A Twitter JSON Search API Example


Photo by OneEighteen

I wanted to add a tag cloud of all the terms people had used in their exchanges, to give an idea of what any two people were talking about. Normally I'd just query my Mailana system directly for the messages' content, but since my server is pretty busy importing new people and generating graphs, I thought I'd try Twitter's search API on the client side, using JSON to load the results.

I'm now using this on http://twitter.mailana.com/ to generate the clouds you see on the bottom left when you look at somebody's profile, but to make it more understandable I've created a standalone example at http://web.mailana.com/labs/twitcloud/

It works by constructing a new script element within the document pulling from the JSON search location. You can supply a callback function name, and that gets called back with the results of the search. View the source to understand what's going on, you're free to reuse any of this code in your own projects with no restrictions.

The biggest drawback is that the search API has been somewhat unreliable for me today, sometimes returning server 500 errors repeatedly, which results in a garbled callback. Despite that I'm still blown away by how much Twitter exposes through their API, it's a developer's dream.

%d bloggers like this: