The Elephant and the Serpent: Using Mastodon with Python


In this talk, we’ll learn what Mastodon is, how it works, how you can participate, and how you can interact with the community using Python. Along the way, we’ll learn about OAuth, APIs, and best practices for writing bots. Attendees will walk away with the knowledge of how to build a Mastodon bot.


  • Intro (3 minutes)

    • Who are we?
    • What’s our history with Python?
    • What’s our history with Mastodon?
  • What is Mastodon and why should you care? (5 minutes)

    • Mastodon is an Open Source social network built on Open Web technologies and principles
    • WebFinger, ActivityPub, OStatus
    • Maintained in the Open, active developer community
    • Funded by Patreon
  • Mastodon is federated! (2 minutes)

    • Anyone can run a server, and see the rest of the network
    • This federation often means resiliency - unlikely for the whole network to be down, only pieces of it
    • You can set up your own server! Or join one that seems friendly
  • Cool, How Do I Use It? (5 minutes)

    • Get an account!
    • Getting a developer token set up - pretty straight forward, no approval process to speak of
    • Wait, what does it mean to have an app on a server? What can it see?

      • OAuth permissions and scopes
      • OAuth and federation
    • Now that we have a token, let’s make some requests using requests

  • Can we do this easier? (5 minutes)

    • Yes! We can use a client library
    • Why would you want to use a client library?
    • Why wouldn’t you want to use a client library?
    • Using the Python Mastodon Client Library (
  • Let’s get our bot posting cool things! (5 minutes)

    • Random Python Fact bot
    • Where to host?
    • How to be a good bot-citizen
  • Q&A (5 minutes)