3

I'm working with the API for several weeks (see my app here) and I'm trying to get the username of a particular user from its Stack Exchange ID.

It's possible by querying /users/{ids} but it returns data from one website at a time, so it will require more requests to get data from multiple users if theirs accounts belong to different websites.

Example:

  1. Get the websites associated to my Account ID and store a website and its user_id
  2. Get the badges associated to my user_id (you may need to associate site_URL with api_site_parameter)

See how the network_user node is present in every badge.

If a global method (returning data from the Stack Exchange network) was available, it should require less requests since it would only take user ids and return only one note per user.

Am I missing something?

If this data is not available, is it possible to add a simple /users/{ids} which returns global data and not on a per-site basis?

Examples:

1 Answer 1

2

The API path you want is /users/{ids}/associatedDoc.
It takes global, Stack Exchange account_ids and returns all the site-specific user_ids for the specified users.

For example, your user_id for Stack Overflow is 2257664 and your global Stack Exchange, account_id is 2606599.
(You can see your /associated results, here.)

You can get user account_ids from any query that returns user objects.

Alas, the /associated paths have two big shortcomings. Perhaps make these your specific feature requests:

  1. The network_user object inexplicably does not return the user's display_name for each associated account!
  2. The /associated paths require account_id, and only account_id. This means that multiple queries must be used.
    A good feature would be if an /associated path accepted, say,
    site=stackoverflow&user_id=2257664
    as an alternate search parameter.



Currently, there is no way to do what you appear to want, without a whole lot of trivial queries. Consider having your app build up, and cache, a table of frequently queried users.

1
  • Thanks for your answer. 1. The problem with associated is that it may return up to 100 results if the user registered on 100 websites, each with the same data replicated. So even if the display_name was available it would be a waste of bandwidth. 2. multiple queries? You can use 1;2;3 to get multiple users. Anyway, I don't want to search on one website only.
    – A.L
    Commented Jan 16, 2014 at 12:49

You must log in to answer this question.

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