If you’ve made the migration over to Mastodon, you’re probably looking to automate a few of your activities using your programming skills. Since I mostly write code using C# and .NET, I thought I would take the time to look at how to do just that. This post isn’t really long, but should make it easier for you to consume RSS feeds coming from Mastodon accounts.
Mastodon Users and RSS Feeds
If you’re new to Mastodon, you probably aren’t aware that everyone’s account can be instantly converted into an RSS feed of their latest posts. Take my account for instance at @khalidabuhakmeh@mastodon.social. Just by adding a .rss
extension to the end of the url of https://mastodon.social/@khalidabuhakmeh
you can convert my profile into an RSS feed. Very neat.
Knowing this, you can now process RSS feeds from your favorite accounts, but you’ll need a little help from .NET.
Mastodon C# Classes and the XmlSerializer
Impowered by the knowledge that accounts also expose RSS feeds, you’ll need to take the XML and turn them into C# objects. Here are the types to deserialize that XML.
Now, it’s as simple as reading the feed from a URL and working with the objects.
Awesome!
Use Cases and Drawbacks
Currently, Mastodon search is dependent on the instance you’ve joined and kind of flaky, if it works at all. You may want to process your own RSS feed periodically and create a searchable store of your interactions online. This can help you recall recurring conversations and reference past events with more accuracy. If you’re looking to do so, I recommend search services like Typesense or Algolia.
Now, the downside. RSS feed results are limited to a certain number of results. I was reliably able to get the last 100 items from my account, but this will likely depend on your Mastodon host. If you need to build a complete history of posts from an account, you might be better off using your instance’s API endpoints.
Conclusion
There you have it. I hope you found this post helpful and I’d love to hear what you’re building with Mastodon.