73

I'm in the data explorer, and I need my user ID for a query. Problem is, I don't know what it is, if it's not my username.

6
  • 2
    Your profile view, meta.stackoverflow.com/users/164012/drm65 - I would think your id is the "164012" segment (on meta).
    – user159834
    Jul 16, 2011 at 16:47
  • I am specifically asking about my ELU account: http://english.stackexchange.com/users/10041/drm65 I would think the same thing (10041), except the query doesn't come up with any results when I input 10041 into here
    – Daniel
    Jul 16, 2011 at 16:50
  • 4
    The data explorer is updated with live data only once per month, usually the first of the month. Perhaps you have to wait a few days to see the desired data.
    – user138231
    Jul 16, 2011 at 17:36
  • 4
    Note that it is different for different sites. A lot of people are suggesting your Meta.SO account, which is all fine and good, but if you want ELU or SO, you need to check those IDs on the user page for that particular site. Jul 17, 2011 at 4:45
  • 5
    You are number 6.
    – Rosinante
    Nov 5, 2011 at 23:26
  • +1 @Rosinante. I'm surprised that nobody ever +1 that until now. (But does that make you number 1, at least for the moment)? Jun 19, 2014 at 4:07

5 Answers 5

40

You can find it in several ways.

  1. The link from your flair on the question contains your id - https://meta.stackexchange.com/users/164012/daniel - in this case it's 164012 here on meta.
  2. Go to your profile page and select the accounts tab. The list of sites links to your profile on that site. So for EL&U the link is https://english.stackexchange.com/users/10041/, so your user id there is 10041.

Your id is different on each site as it depends on when you joined the site and how many people had joined before you. This means that if you just change the site name in the profile url you won't get your account on that site, you'll almost certainly get someone else's. The only exception to this is this site for those users who existing on Stack Overflow when Meta was first created. In that instance Jeff just copied the user table so we have the same id.

There is also your network id - https://stackexchange.com/users/429575/daniel - in your case.

5
  • 1
    But 10041 doesn't work in the query.
    – Daniel
    Jul 16, 2011 at 16:54
  • 2
    @drm65 - I don't know. That is your profile. How long have you been a member of EL&U? The data explorer data is always at least one month out of date. So if you're less than a month on the site you won't appear just yet.
    – ChrisF Mod
    Jul 16, 2011 at 17:00
  • 1
    @drm65 ChrisF is correct. That query works for other userIDs whose owner joined earlier than you.
    – Bill
    Jul 16, 2011 at 17:05
  • 1
    @ChrisF: Ahhh... that must be it. I've only been on SE for 29 days.
    – Daniel
    Jul 16, 2011 at 18:50
  • The 2nd way doesn't work anymore. Can you confirm and update your answer ?
    – Suhaib
    Jul 21, 2014 at 22:48
15

You can find your user ID for a particular Stack Exchange site by performing the following steps:

  1. First, visit your user profile on the site in question.

  2. Take a close look at the URL for your profile page:

    The 5 represents the user ID

  3. You should spot a number right after the users/ and before the slug for your username. This is your user ID for that site.

3
  • 3
    You felt the other answers didn't adequately explain this? Nov 5, 2011 at 20:22
  • 2
    @MichaelMrozek: Actually, to be honest, I'm writing a PHP library for the API and I needed a single answer somewhere that clearly described how to retrieve a user's ID. None of the other answers seemed to do that. Nov 5, 2011 at 20:40
  • +1 this answer is indeed more clear than the others. Nov 6, 2011 at 8:29
7

Your user ID is 164012. You can find it in the url of your user page: https://meta.stackoverflow.com/users/164012/drm65

1

Get all stackexchange user ids for a user

Find your user-ID of your Network Profile in your user section, then you can get all other IDs with this bash script:

ID=429575
USER=daniel
curl https://stackexchange.com/users/$ID/$USER?tab=accounts|grep account-container -A1|grep http|cut -d"/" -f3,5

This will give you a list of all SE-sites and user-ids.

If you need a list of all questions and answers:

#/bin/bash

SE_ID=429575
U=daniel

users=$(curl https://stackexchange.com/users/$SE_ID/$U?tab=accounts|grep account-container -A1|grep http|cut -d"/" -f3,5|xargs)
for i in $users; do
  site=$(echo $i|sed "s~/.*$~~g")
  id=$(echo $i|sed "s~^.*/~~g")
  for a in questions answers; do
    URL=http://$site/users/$id/$U?tab=$a
    echo $URL
  done
done
2
0

Your user ID is different on each SE site; in the list of user profiles listed, for example, in https://meta.stackoverflow.com/users/164012/drm65?tab=accounts, the user ID is always the number after users/.

The one you need to use depends on where you are executing the query: The one that you need to use in https://data.stackexchange.com/stackoverflow/queries is your Stack Overflow user ID, while in https://data.stackexchange.com/english/queries you should use your EL&U user ID.

You must log in to answer this question.

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