Search code examples
apimastodonmicroblogging

How do I get all the toots in Mastodon API to delete them?


How can I get all the toot IDs that I've tooted?

I want to delete all of my toots (status posts) at Mastodon but can't get all the toots.

It would be easier if I delete my account, though I want to keep my account alive and clean up all the mess that my NEWS-BOT did.

It seems that currently, Mastodon doesn't have the ability to delete all the toots as a standard feature.

So I tried to delete them using the Mastodon API recursively as below, but couldn't get all the Toot IDs (Status IDs) for deletion.

  1. GET Toot IDs from /api/v1/timelines/home endpoint.

    curl -X GET --header 'Authorization: Bearer <ACCESS_TOKEN>' -sS https://sample.com/api/v1/timelines/home

  2. DELETE a toot at /api/v1/statuses endpoint with Toot IDs that I got.

    curl -X DELETE --header 'Authorization: Bearer <ACCESS_TOKEN>' -sS https://sample.com/api/v1/statuses/<Toot ID>

  3. Loop 2 then 1 until empty.

It cleaned up the home timeline. But many toots were left on the public profile page. I also tried to get the IDs from the ATOM feed but didn't help.

All I need is the list of my Statuses IDs that I'd tooted. Any ideas?


Current Conclution

As of @unarist's advice,

API endpoint

https://sample.com/api/v1/accounts/<account id>/statuses

GET /api/v1/accounts/:id/statuses

will do the fetching.

Though, there are 3 points to be noted:

  1. By default, this API method gives you only 20 status(toot info) and max 40.
  2. Authorized API request are limited to 300 requests / 5min (1 request/sec).
  3. Therefore, you can delete NO more than 84,240 toots/day.

It seems that I had over requested and couldn't get the info I needed. So better be careful about the server's message! (>_<)/

Have a good Mastodon time!


Solution

  • Home timeline contains not only your posts but also posts from your followings, and the server only keeps recent posts (400 items by default) of each home timeline. Therefore, you cannot enumerate all your posts from it.

    Use account statuses API with your account id:

    https://sample.com/api/v1/accounts​/<account id>/statuses

    This API is what WebUI uses on your profile page (/web/accounts/xxx).