How do I can find someone's userid if I have only their username?
For example, my real username is: Zagorulkin Dmitry
My Stack Overflow userid is: 1321404
Are there any API methods for this kind of task?
To find user_id
(s) for a username, use the inname
parameter of the /users
query.
You will have to repeat this query call for every Stack Exchange site that you are interested in. For example:
If you only want the user_id
, create a filter to that effect. For those two example queries, I used a filter to return just the user_id
and the account_id
; resulting in:
{"items":[{"user_id":1321404,"account_id":1390443}],"quota_remaining":263,"quota_max":300,"has_more":false}
and
{"items":[{"user_id":57385,"account_id":1390443}],"quota_remaining":262,"quota_max":300,"has_more":false}
respectively.
The account_id
is useful, because once you know it, you can use
/users/{accountId}/associated
to get all of the user's associated account info.