What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 128 Stack Exchange communities.

There are lot of SO gadgets out there. But we have to enter the userid (number) instead of username. It will be good if we have an API to get userid from username.

Example gadget below from an SO user.

  1. http://insomniacgeek.com/code/windows-gadget/a-stack-overflow-sidebar-gadget/
share|improve this question
8  
not possible, as user names are not unique –  Jeff Atwood Jul 18 '09 at 13:29
    
Funny for those who say it's not possible. It only took me about 45 minutes to implement. –  Joel Coehoorn Feb 3 '10 at 3:19

4 Answers 4

I think it's not possible. I could change my username to Shoban and the system wouldn't be able to choose between my id and your id. Username is not unique, id is.

share|improve this answer

Who says it can't be done? Here you go:

http://data.stackexchange.com/stackoverflow/query/104038?Name=Joel+Coehoorn

You can also get back csv data, like this:

http://data.stackexchange.com/stackoverflow/csv/126464?Name=Joel+Coehoorn

And a C# class to get the results (untested/typed directly into edit window):

public static class DataExplorer
{
    private const string baseUri = "http://data.stackexchange.com/stackoverflow/csv/";

    public static IEnumerable<int> UserIDsFromDisplayName(string DisplayName)
    {
       string queryData = "?Name={1}";
       query
       bool Header = true;    
       foreach (string id in RawQuery(126464, string.Format(queryData, DisplayName.Replace(" ", "+").Split('\n')[0]))
       {
           if (Header)
           {
              Header = false;
              continue;
           }
           yield return int.Parse(id);
       }
    }

    // data returned in a csv string
    private static string RawQuery(int queryID, string queryData)
    {
       using (var wc = new WebClient())
       {
           return wc.DownloadString(baseUri + queryID.ToString() + HttpServerUtility.UrlEncode(query ?? ""));
       }
    }
}
share|improve this answer

Go to the Users Search, type in the username you want, and get the id from its URL. Simple as pie :)

share|improve this answer

Actually, since username can be duplicated, it is NOT simple as pie. In fact I think it takes multiple calls in all except a few instances as you try to triangulate the actual user. If you have a post from the user then you have a chance.

I have asked for the actual user ID to be embedded in the search feed, which would make it much simplier to get from question to person.

Embedding UserId in Questions Feeds/API

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .