How to get Mastodon's user ID from Mastodon account (acct, username & server)?

The thing is, you can actually use the /api/v1/accounts/:id API to get detailed information about an account (without authentication), but you cannot do so without knowing the account ID.

You can use WebFinger to get some stats about an account, but Mastodon’s account ID is missing… :thinking:

So when you only know the Mastodon handle, i.e. username & server, how can I get the ID from that?

My actual use case is to just use the data then returned to embed/show the avatar image/icon of the user.


I have the same question. I am not a Mastodon user, so I do not know how to approach: I would like to retrieve the avatar but all I know is the @user@server information from the user. Is there a way to get the ID from that information, so that I can use the API?
As a workaround, I could scrape the address https://server/@user (if the robots.txt allows for it) and extract the #profile_page_avatar. But clearly, using the API would be much better.

Help would be appreciated!

Bumping this thread. My use case is that I’d like to load my latest updates from a mastodon server into my website without using tokens, for example using GET /api/v1/accounts/:id/statuses, but I have no idea where I can find my id

You don’t need API to get the latest public posts from a user. Every user has an rss feed. If you append .rss to the URL of the user profile you will get the rss feed and can parse that on your end.

profile: https://instance.tld/@username
rss: https://instance.tld/@username.rss

All right, that’s cool. I still prefer to use the APIs though which are in JSON and are more flexible, but definitely something that’s good to know.

I don’t think you can get the user ID from the web interface if you are just a user. A moderator or admin of the instance of your account can go to Preferences->Moderation->Accounts and find your account. After opening the account details, the URL will reveal the ID of the user. If you are not the admin of your instance you can try and ask them to do that for you. That’s the only way I can think for you to get the ID without generating tokens.

I’ve found support on Freenode, it is possible and as simple as clicking on your handle in the main web page and it will be shown in the URL.

I personally think this is a bug, it should be highlighted somewhere in the Developers settings section, but apparently devs think differently.

What about /api/v2/search:

curl '' 
    -H 'Authorization: Bearer xxxxx' 

The first account returned is mine:

  "id": "18021",
  "username": "saper",
  "acct": "saper",
  "display_name": "Marcin Cieślak",
  "locked": false,
  "bot": false,
  "discoverable": false,
  "group": false,
  "created_at": "2016-12-17T10:22:21.239Z",
  "note": "<p>Internet is a read/write medium. </p><p>Fax+496925577122</p>",
  "url": "",
  "avatar": "",
  "avatar_static": "",
  "header": "",
  "header_static": "",
  "followers_count": 820,
  "following_count": 669,
  "statuses_count": 11279,
  "last_status_at": "2020-06-20",
  "emojis": [],
  "fields": [
      "name": "Politics",
      "value": "The art of decision making",
      "verified_at": null
1 Like