Christian Heilmann

flickr.whois – using YQL to find Flickr user data from user ID or user name

Thursday, May 14th, 2009 at 2:24 am

One of the very frustrating things about Flickr is that there is a difference between user ID and user name when it comes to accessing the data via the API or even RSS. For example I can get to my home page via but the RSS feed url is

The user name doesn’t work, you need the user ID (which is normally in the format of 11414938@N00). Getting this ID is not straight forward which is why there is the flickr.urls.lookupUser API method and several tools that do this for you.

However, I wanted to get more than just the ID from the name or the name from the ID. Using YQL, this was pretty easy.

I knew I could do a search for photos by providing the user id (try in console):

select * from where user_id=”11414938@N00”

This returns a single photo and I can use its ID to get to the rest of my user data by reading out the owner (try this in the console):

select owner from where photo_id in
(select id from where user_id=”11414938@N00”)

This returns all my user information which is cool, but I needed to find a way to match user name and ID. So I looked at the source code of my flickr page and found a hidden form field with the name “w” and the value of my nsid:

finding your nsid on the flickr homepage by  you.

Using this knowledge, I could get the NSID from a user name with a simple HTML scraper (try scraping in console)

select value from html where url=””
and xpath=”//input[@name=’w’]”

Putting this together, it was easy to build a JavaScript that returns the information for any user given an NSID or the user name:

var yql;
yql = ‘select owner from where photo_id in ‘+
‘(select id from where ‘;
yql += ‘user_id=”’ + owner + ‘”’;
} else {
yql += ‘user_id in (select value from html where ‘+
’ url=”’ + owner + ‘” and ‘+

yql += ‘) limit 1’;

Encased in a YQL execute table this can now be used to get the user data for either an NSID or a user name (try the open table in console).

use “” as flickr.whois;
select * from flickr.whois where owner=”sdeschamps”

Try it out:

If you want to shorten the results, add the “diagnostics=false” to the URL and use JSON as the output.

Share on Mastodon (needs instance)

Share on Twitter

My other work: