My Mastodon bots, and how to easily run your own

30 minutes

One of the great aspects of Mastodon is that it very simple to run your own bot on the platform. Setting up API credentials is a breeze, and you can start reading or sending toots in a matter of minutes. There are very good docs on how to use the API. There is also a Mastodon Python SDK, a wrapper for the HTTP queries, that makes writing bots even simpler if you already know the language.

I am currently (January 2024) running two bots on Mastodon, both of them I wrote myself and I am hosting them on my VPS, the one which is also hosting this blog.

Astrobin Image Of The Day

Astrobin Image Of The Day is a bot that every afternoon posts the Image Of The Day from Astrobin (duh). Astrobin is an online gallery for astrophotographers to showcase their work, and every day there is an Image Of The Day chosen by a selected jury. Using Python and BeautifulSoup I am parsing the IOTD page, extracting the url and some metadata, and composing a toot with a link to the prized image. This bot has been running for six months now and is slowly building a group of followers. The source code for it is available at

Energetyka Polska

Energetyka Polska (Polish Energetics) is my new bot, deployed only a few days ago. It posts Polish-specific data, so it’s in Polish. Every two hours it pulls data from Electricity Maps API and publishes stats about the state of electricity production in Poland, which types of power plants produce how much electricity, and what is the percentage of renewables and low emission sources in the Polish energy mix. Electricity Maps’ API is very simple to use, and with posting twelve times a day, I am well within their free tier. The source code for it is, again, available at

Running your own Mastodon bot

Why would you want to run a bot? It’s a nice, short project, good way to practice a programming language of your choice, and allows to show your work to the world without doing complicated deployments, the heavy lifting being handled by the Fediverse.

First a word of caution: When considering creating a bot, please make it for something good, to share interesting data, to alert about important stuff, to make people’s life better. OK? Thanks! Don’t be a spammer.

To make creating bots even easier, I have created a template project in Python that you can use. It’s available here at my Codeberg repo. Feel free to fork it, or just download, amend to your needs and run.

I believe the README file says everything required to run and deploy the bot, but if something is missing, please let me know. Running the bot requires only basic Python and Linux skills, and should be of no problem for anyone who ever touched the terminal.

One thing to consider when deploying a bot is choosing the instance for it. There are instances dedicated for bots, like, or you can choose a generic one. Please, however, check each time the instance’s rules whether it allows hosting bots, and what are its rules regarding acceptable types of content.

Next you will need a place for it to run. It kind be any type of Linux* machine, even a Pi Zero, or an ancient Thinkpad will do. Basically anything that can run Python and cron. Deployment instructions, again, can be found in the repo’s README file.

*Windows or Mac, probably could also work, but come on, who uses them? Not me.

If you would like to contribute to the repo, hit me up, we can make it a group project!

And that’s it! If you are going to use the template for your own bot, it would be awesome if you could tag me somewhere as the owner, and also please consider supporting me using the sites below. That would be lovely, but don’t feel obligated, it is free software, as in free speech, and as in free beer :)