I'm trying to modify this userscript of mine to make it work on all sites but I couldn't find a way to get the account ID (i.e., network profile ID) for a user.
Is this possible?
I'm trying to modify this userscript of mine to make it work on all sites but I couldn't find a way to get the account ID (i.e., network profile ID) for a user.
Is this possible?
The 2.3 SE API has a account_id
property on the shallow_user
object, which is the user's SE account ID, so you can get the user's SE account number from any request which returns that object as part of the response (e.g. any question, answer, post, etc.). Adding that property was one of the changes in the 2.3 SE API and allows you to obtain the user's account ID from many endpoints as part of getting other data. Getting the account_id
from such endpoints can be a significant savings in request quota, depending on what you're doing.
If you are wanting to make a request specifically to get the account_id
, you can get that property in the user
object returned by the /users/{ids}
endpoint. That account_id
property is the user's SE account ID.
Once you have the account_id
, you could use the /users/{ids}/associated
endpoint to get the IDs for all of the profiles associated with that SE account on different sites.