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/
  • 8
    not possible, as user names are not unique Jul 18, 2009 at 13:29
  • 1
    Funny for those who say it's not possible. It only took me about 45 minutes to implement. Feb 3, 2010 at 3:19
  • It seems you can't get a unique userid but it is possible to get a list of userids that have a given username. Seems good enough for me.
    – simlev
    Mar 15, 2017 at 10:43

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.


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


You can also get back csv data, like this:


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

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

    public static IEnumerable<int> UserIDsFromDisplayName(string DisplayName)
       string queryData = "?Name={1}";
       bool Header = true;    
       foreach (string id in RawQuery(126464, string.Format(queryData, DisplayName.Replace(" ", "+").Split('\n')[0]))
           if (Header)
              Header = false;
           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 ?? ""));

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


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

You must log in to answer this question.

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