Twitter API User Bulk Lookup!

UPDATE: Of course you’ll need to upgrade to do the OAuth dance now to make these calls. Back when this post was written, the HTTP Basic Authentication option was still available to developers.

The Twitter API Team introduced a new method this evening that will be incredibly useful.

You can now batch user lookups by username or ID with one call:

$ curl -u username:password
  "https://api.twitter.com/1/users/lookup.xml
  ?user_id=756264,10145822"

or

$ curl -u username:password 
  "https://api.twitter.com/1/users/lookup.xml
  ?user_name=damon,podlabs"

both return:

<?xml version=”1.0″ encoding=”UTF-8″?>
<users type=”array”>
<user>
<id>756264</id>
<name>Damon Clinkscales</name>
<screen_name>damon</screen_name>
<location>Austin, TX</location>
<description>Father. Husband. Friend. Connector. Helper. Programmer. VitalSource. Podlabs. Austin on Rails.  Cafe Bedouins. SnapTweet. DoesFollow. WhereBeYou.</description>
<profile_image_url>http://a1.twimg.com/profile_images/561257818/mo5_crop_normal.jpg</profile_image_url>
<url>http://blog.damonc.com</url>
<protected>false</protected>
<followers_count>1436</followers_count>
<profile_background_color>ec2727</profile_background_color>
<profile_text_color>051014</profile_text_color>
<profile_link_color>1b3c5f</profile_link_color>
<profile_sidebar_fill_color>AF2C2C</profile_sidebar_fill_color>
<profile_sidebar_border_color>F2E195</profile_sidebar_border_color>
<friends_count>500</friends_count>
<created_at>Wed Feb 07 19:41:27 +0000 2007</created_at>
<favourites_count>138</favourites_count>
<utc_offset>-21600</utc_offset>
<time_zone>Central Time (US &amp; Canada)</time_zone>
<profile_background_image_url>http://s.twimg.com/a/1268246301/images/themes/theme2/bg.gif</profile_background_image_url>
<profile_background_tile>false</profile_background_tile>
<notifications>true</notifications>
<geo_enabled>false</geo_enabled>
<verified>false</verified>
<following>true</following>
<statuses_count>14879</statuses_count>
<lang>en</lang>
<contributors_enabled>false</contributors_enabled>
<status>
<created_at>Thu Mar 11 07:33:18 +0000 2010</created_at>
<id>10312311768</id>
<text>Damon, what are you doing up, you may ask…why, I’m programming the @twitterapi. so far, our diabolical plan w/ the little one is &quot;working&quot;</text>
<source>&lt;a href=&quot;http://www.atebits.com/&quot; rel=&quot;nofollow&quot;&gt;Tweetie&lt;/a&gt;</source>
<truncated>false</truncated>
<in_reply_to_status_id></in_reply_to_status_id>
<in_reply_to_user_id></in_reply_to_user_id>
<favorited>false</favorited>
<in_reply_to_screen_name></in_reply_to_screen_name>
<geo/>
<coordinates/>
<place/>
<contributors/>
</status>
</user>
<user>
<id>10145822</id>
<name>Podlabs</name>
<screen_name>podlabs</screen_name>
<location>Austin, TX</location>
<description>Software ideas, realized.</description>
<profile_image_url>http://a3.twimg.com/profile_images/744436899/PLtwitbig_normal.jpg</profile_image_url>
<url>http://podlabs.com</url>
<protected>false</protected>
<followers_count>13</followers_count>
<profile_background_color>131516</profile_background_color>
<profile_text_color>333333</profile_text_color>
<profile_link_color>009999</profile_link_color>
<profile_sidebar_fill_color>efefef</profile_sidebar_fill_color>
<profile_sidebar_border_color>eeeeee</profile_sidebar_border_color>
<friends_count>3</friends_count>
<created_at>Sun Nov 11 05:57:50 +0000 2007</created_at>
<favourites_count>0</favourites_count>
<utc_offset>-21600</utc_offset>
<time_zone>Central Time (US &amp; Canada)</time_zone>
<profile_background_image_url>http://s.twimg.com/a/1268246301/images/themes/theme14/bg.gif</profile_background_image_url>
<profile_background_tile>true</profile_background_tile>
<notifications></notifications>
<geo_enabled>false</geo_enabled>
<verified>false</verified>
<following></following>
<statuses_count>23</statuses_count>
<lang>en</lang>
<contributors_enabled>false</contributors_enabled>
<status>
<created_at>Wed Mar 10 17:02:41 +0000 2010</created_at>
<id>10279681545</id>
<text>@willie Oh, THAT Death Star. I was thinking about a different floating orb evil empire. I’m glad to hear you think it’s much improved.</text>
<source>&lt;a href=&quot;http://www.atebits.com/&quot; rel=&quot;nofollow&quot;&gt;Tweetie&lt;/a&gt;</source>
<truncated>false</truncated>
<in_reply_to_status_id>10278766590</in_reply_to_status_id>
<in_reply_to_user_id>796105</in_reply_to_user_id>
<favorited>false</favorited>
<in_reply_to_screen_name>willie</in_reply_to_screen_name>
<geo/>
<coordinates/>
<place/>
<contributors/>
</status>
</user>
</users>

Two issues come immediately to mind that this helps out with:

  1. Search API user ids still do not match REST API user ids. So with this, you could pull search results and map the screen name to the REST API user id. The fact that you can do this in bulk will save billions of calls. 🙂
  2. The so-called Social Graph methods, where you can pull a Twitter users’ friend list or following list as a big list of IDs are extremely useful, although they have, to date, only supported IDs in the responses. So with this new call, you could take a social graph of IDs and run them through this bulk lookup to get the screen name. Once you have the screen name, you can create links to the user’s twitter profile, for one thing. This bulk lookup also returns the entire User resource, so at that point you’ve got everything.

Great change. Nice work, Twitter API guys!

Idea #2: Twitter Lists “What Others Think of You” Cloud

Use the list names (take each word between the hyphens) and group them together into a group. So this is a fun little site to see what others think about you. And if the person is popular at all, you should pretty quickly hone in on some key factors about the person.

So for example…these are the lists that I’ve been added to as of November 2009:

@marascio/austin
@marascio/programmers
@davidgiesberg/conversationlist
@jeremya/austin-developers
@takayama/iphone-sdk-users
@MrSamHall/sinatrarb
@moomoney/austin
@jdirt/rails
@jotto/conversationlist
@Tweet_Tool/tweet-apps
@latenitecoder/developers
@konstantinhaase/rubyfolkstowatch
@trey/rails
@danielmorrison/met
@EvilPRGuy/peopleyoushouldmeetirl
@ozmox/met-in-real-life
@ozmox/ruby-on-rails-folk
@twmills/austin
@twmills/austinonrails
@nertzy/austin
@Madabip/twitter-peeps
@orchid8/austin
@josh_wills/friends
@tsmyther/rubyists
@tsmyther/mac-gurus
@austindirtydog/austin-peeps
@Scobleizer/twitter-tools-and-devs
@hgimenez/rb
@jpinnix/my-favstar-fm-list
@ericstewart/programming
@rbandrews/rails
@HeatherJStrout/austinfolks
@twtlist/twit
@lgharp/nerds
@BUNCH/austin
@hayesdavis/l33t
@infochimps/austintech
@mrflip/core
@mrflip/austintech
@jc00ke/ruby
@entangledstate/rubyists
@wesley83/met-irl
@njonsson/rubyists
@chris24/tweets-most-favorited
@the_api_book/developers
@kmakice/twitter-research
@jpinnix/programmers
@chris24/ruby
@DustyReagan/austin-techies
@BaldMan/austintech
@DustyReagan/twitter-developers
@Bringo/rails
@jcsalterego/bedouins

Looking at this, you can probably surmise that I’m in Austin, work with Ruby and Rails, and am a programmer.

Now, due to the Twitter AJAX page loading, you don’t get all of the lists in one shot. You get 20 at a time. Therefore, it is difficult to quickly scan all lists and form an opinion without some help. This is especially true for people featured on hundreds of lists. So, the tool would grab all the lists (yes, you have to cursor through, but it shouldn’t be too bad) and break down the words into a frequency list.

Then take the word list and say that any word that appears more than 10% of the time must be important. Some kind of metric. You could filter out known services like conversationalist or favstar. You could run the words through a dictionary.

I’m surprised someone hasn’t done this already. But I’m just saying it’d be really useful if you could type in someone’s name and get a quick read on what others think of them.

Known Implementations:

Related:

DoesFollow Adds Twitter List Support!

With the recent introduction of Twitter Lists, Twitter has given us a great new way to discover folks on Twitter. Each list can have up to 500 members. If you’re wondering if you or someone else is on a specific list, we’re back to paging through to find the answer, just like we used to do with followers (before doesfollow.com launched last summer).

I was poking around the lists I’ve been added to and I happened to notice that @damon had been followed by @Scobelizer‘s Twitter Tools and Devs list. Interesting. So I started paging through trying to see if he had added my most popular apps. He had added SnapTweet, but I didn’t find DoesFollow.

I realized at that moment, what we all really needed was a simple Twitter List membership check:

Home Screen:


twitter lists membership check

Result Screen:


twitter lists membership check

Please give it a try and let me know if you have any feedback!