For my app, I allow people to "register" themselves on my site by typing in their Stack Overflow (etc) name. Now it does allow you to use your ID if you know it, but I find that typing in usernames is much more user-friendly.

In the back end, if someone enters a name, I do a query to /users?filter=<name> and look at the results. So if you enter my name, "codeka", or "Jon Skeet" or something else which is unique on the site it comes back with a single response and I just use that directly. If you type in something like "John", there's 1,287 users that come back for /users?filter=John.

The problem is that if your name on the site is exactly "John", then you might find that you're way down the list somewhere. Rather than requiring users to page through the list to find themselves, I'd like to have some way to specify that "filter" returns exact matches only. So if you entered /users?filter=John&exact=true (say) then only users whose names are exactly "John" would come back.

That way, I could still display the list as I do, but then I could make it so that exact matches appear at the top.

Does that seem reasonable?

  • Your app could refilter what the API returns. Commented Jun 7, 2010 at 4:26
  • @Dennis: the problem is that to get all of the exact matches for "John" I would have to download all 1,287 results from the API before displaying them to the user to choose. That's 43 requests... by adding an exact=true parameter, then I could do it in a single query.
    – codeka
    Commented Jun 7, 2010 at 4:28
  • Wouldn't it be better to identify them using their openID that they'd already have on Stack sites anyways? That way you also don't have to write your own authentication system.
    – Soviut
    Commented Jun 7, 2010 at 6:51
  • @Soviut: The user's openid isn't public
    – balpha Staff
    Commented Jun 7, 2010 at 6:53
  • @Soviut: It's not actually for authentication, the "registration" is just adding users to a list that my app monitors for reputation changes (among other things) - you can "register" any user you like. Basically just an easier method than having to find your user ID.
    – codeka
    Commented Jun 7, 2010 at 7:35
  • I was just hoping for this feature as well. I don't need to authenticate the user, I just want them to type a user by their name. Looks like there's a non-ideal way of doing it. It would be nice if the API had this scenario explicitly handled somehow. Commented Jun 8, 2010 at 15:39
  • @InfinitesLoop: that's my idea as well, just as a way to identify yourself via your name rather than ID. Of course, there's some people with the same name, but in my experience they're a minority and it's easy to show a list of all the people with the same name if that's the case.
    – codeka
    Commented Jun 8, 2010 at 23:18
  • min/max on users by name is now case insensitive resulting in a viable 'exact match'. e.g. min=john&max=john see stackapps.com/questions/1060 Commented Jul 9, 2010 at 17:14
  • you may now reformat your q into a how-to as there is but one means to this end. you may want to rephrase the q to something like 'how to find all users with exactly matching display name' or some such. a dev-tip tag might not be a bad idea either. Commented Jul 9, 2010 at 17:21
  • url broken in the first sentence.
    – user8160
    Commented Sep 14, 2011 at 18:38
  • @hhh: this was from over a year ago... my app is no longer online anyway, it basically did what you can now see here: stackexchange.com/leagues
    – codeka
    Commented Sep 15, 2011 at 12:34

2 Answers 2


Actually, I think I figured out a way to do this. If you specify the following:


That is, sort by name with "min" and "max" both set to "john" then it returns only those people whose name is exactly John. I wonder whether this efficient for the backend to process? It seems to respond pretty quickly, which is a good sign.

One interesting point is that it seems to be case-sensitive:


Only returns the 24 users whose name is "john" (lower-case "J") but with max=JOHN then I get 224 users whose name is "John" or "john".

With such a large number of exact matches, though, I wonder what the best way to present that is? Just say "there are 224 users with the name 'John', here's the first 30 and if you can't find yourself you'll have to enter your user ID manually"? Maybe this is a corner-case and I'm thinking about it too much :)

  • Just thinking about this, min=john&max=JOHN would actually include "gohn" I believe... I'll still have to filter on the client-side. It seems a bit odd that filter is case in-sensitive, but min&max are case-sensitive.
    – codeka
    Commented Jun 7, 2010 at 10:15

UPDATE: min/max on users by name is now case insensitive resulting in a viable 'exact match'. e.g. min=john&max=john see should min/max for alpha-numeric cases be case-insensitive?

the min/max solution that codeka presents seems to work great. While it does not guarantee accurate results, it does drastically reduce network traffic.

I simply check again when I get the results back and filter out non-matches client side, e.g.

Soapi.RouteFactory(site.api_endpoint, apiKey)
        min: username.toLowerCase(),
        max: username.toUpperCase(),
        sort: Soapi.Domain.UserSort.name
        $.each(data.items, function(ignored, user)
            if (user.display_name.toUpperCase() == username.toUpperCase())

                // set the site so we can render links and logo.
                // this can be refactored down to a literal with needed fields only
                user.on_site = site;


You must log in to answer this question.

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