DEV Community

Karin
Karin

Posted on • Originally published at khendrikse.netlify.app on

How to find your Mastodon account ID

If you're trying to set something up with the public Mastodon API, you might need your account ID. This is one of the ways you can find your ID.

You can find your mastodon account ID by doing a call to the following URL.
Replace INSTANCE with the name of the server you are on. If you're on mastodon.online for example, it will be mastodon.online.

Replace USERNAME with your username.

https://INSTANCE/api/v1/accounts/lookup?acct=USERNAME
Enter fullscreen mode Exit fullscreen mode

Now you can either visit that URL in the browser, or use curl in your terminal:

curl https://INSTANCE/api/v1/accounts/lookup?acct=USERNAME
Enter fullscreen mode Exit fullscreen mode

Both will return an object holding your id.

{
  "id": "1",
  "username": "fakename",
  "acct": "fakename",
  "display_name": "A fake name",
  "locked": false
  // ...
}
Enter fullscreen mode Exit fullscreen mode

If you want to know more about this endpoint. Check out the documentation. Hopefully this can help people to quickly find their account ID.

Top comments (1)

Collapse
 
andypiper profile image
Andy Piper

Nice!

Couple of things to note:

  • if you move between instances, the ID will change. This is not like Twitter, were the ID of an individual account remains the same even when the username changes (of course, Twitter is not a dsitributed federated system!)
  • you can also get the ID of your authenticated account via the API using the /api/v1/accounts/verify_credentials method, but you need to use a Bearer token when calling that endpoint.