5

If I have the ID of a user from any site, how can I get that's user's ID for a site I specify?

Eg. If someone's ID was 10349 on Super User, how could I get 10349's id on Stack Overflow?

I know I'd be able to use associated_users, but that's only if I have the user's main SE profile's ID, right?

Is it possible to do this?

1 Answer 1

4
  1. Use the /users/{ids} route to get account_id.
  2. Then pass the account_id to /users/{ids}/associated.

Note that account_id is exactly the kind of information that should be heavily cached by your script/app. (Hint, hint; wink, wink; nudge, nudge. (^_^) )

For example:

/2.2/users/10349?site=superuser&filter=!T6o*9deY.2ZD3-(n4f

Returns:

{
  "account_id": 1605,
  "reputation": 178,
  "user_id": 10349,
  "display_name": "On Freund"
}

Then:

/2.2/users/1605/associated?filter=!--KJWbRC6EPM

Returns:

{
  "question_count": 5,
  "answer_count": 117,
  "last_access_date": 1431898687,
  "creation_date": 1219247035,
  "account_id": 1605,
  "reputation": 3612,
  "user_id": 2150,
  "site_url": "http://stackoverflow.com",
  "site_name": "Stack Overflow"
},
{
  "question_count": 2,
  "answer_count": 1,
  "last_access_date": 1428968656,
  "creation_date": 1252397718,
  "account_id": 1605,
  "reputation": 178,
  "user_id": 10349,
  "site_url": "http://superuser.com",
  "site_name": "Super User"
}
0

You must log in to answer this question.

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