views:

87

answers:

2

I'm trying to develop a stackoverflow.com widget for Mac OS X and I'd like to show the flair for a given username.

The different possibilities described in User Flair are all expecting the ID of a user but I'd like to let the user enter a username, instead.

Is there any way to retrieve the userID for a given username?
Better yet, is there some AJAX usersearch callback that would suggest completions after parts of the username have been entered?

+1  A: 

I dont think it is available. I had the same issue when I developed an wordpress sidebar widget. May be we can expect it soon ;-)

Shoban
+1  A: 

This won't be possible. At best, you'll get a list of userIDs that have the given username, because usernames are not unique, as I've demonstrated by changing mine (temporarily) to Huxi.

You could ask for a username + email address, do a search for the username using the users filter:

http://stackoverflow.com/users/filter/huxi

Then MD5 the email address and match to the Gravatars, and you have your userID.

This will work maybe 90% of the time. It will NOT work, however, when the username is common (the "API" will return at most 35 possibilities), or when the user has not provided an email address to StackOverflow. With these limitations in mind, it's probably easier just to ask the user to locate their ID themselves.

Kyle Cronin
LOL, very nice proof of your point :DI see, thanks for this clarification ;)
Huxi
Thanks for replying, I was wondering when I could switch my username back ;-)
Kyle Cronin