Archive and Search your Mastodon Bookmarks locally

The Fediverse is a collection of server instances connected to each other, one popular software that many use is Mastodon - I use it to get my 'social network' fix regularly. It has a nice feature that lets you bookmark posts as they stream across your timeline.

I've seen people joke about the uselessness of this feature. Maybe they aren't aware that searching in:library [keywords] will let you quickly find posts that you have bookmarked.

However, there are at least two situations when it won't work:

  1. Your Mastodon instance is not configured with ElasticSearch - which requires as many GBs of RAM as you afford to throw at it - for my single-user instance, it ate up all of the 6 GB the machine had - leaving no room to host anything else. I disabled it soon after.
  2. You want to search your own posts that you bookmarked. Putting in:library from:me shows me my most recent posts and replies, not bookmarked posts from me.
  3. Bonus situation: You lose access to your account or the instance shuts down before you've exported your bookmarks.

This has bugged me enough to attempt creating a small utility that polls my instance periodically and stores bookmarks in a local SQLite3 database with full-text search index and a web-ui that I can access via my phone or laptop.

I used GitHub Copilot to generate the code - using LLMs allowed me to have the utility I have attempted to write by hand before, but for reasons I'll cover in another post someday, I never got around to finishing the 7 prior attempts.

Since this program is intended to be hosted privately on my home server, behind VPN-only access, I am okay with not having any auth (access control lists allow only my phone and laptop to access the service). I did spend some time verifying that rate limits for API calls work as expected, as I do not want to abuse the API nor hit rate limits.

You will need an auth_token from your Mastodon instance to use this - it can be found under Settings > Development. Copy the config.toml.sample to config.toml and add your instance url and the auth token. By default, bookmarchive looks for the config file in current dir. Override that behaviour with --config PATH option.

It works - and does its one job well enough to share the code (CC0 licensed/ public domain) with anyone else who has this particular need: https://github.com/hiway/bookmarchive The releases page also has binaries if you want to give it a whirl without requiring the Go toolchain.