Analysing which Mastodon apps I've used
Tags: mastodon, python, datascience
Published: 2023-01-29 23:51:56

A few months ago, I wrote about [the opportunities for developers around Mastodon](https://dev.to/andypiper/a-opportunity-for-developers-1ee4). 

{% embed https://dev.to/andypiper/a-opportunity-for-developers-1ee4 %}

Since then, I've been excited to see the different apps popping up around the Mastodon ecosystem - on iOS alone, the past fortnight saw [three or four impressive new client apps emerge](https://macaw.social/@andypiper/109745925959612756) (and more are in testing), plus excellent Progressive Web Apps like [Elk](https://elk.zone) are gaining attention.

![Toot reading: "With @ivory @icecubesapp and @tusker all moving from TestFlight to App Store in the space of a few days, it is an exciting time. I remain excited to see what developers build on Mastodon (and ActivityPub). It would be great to see more options for web embeds, sharing etc, and greater diversity of Android apps too"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nc460cz3z9qvvyse1hc9.png)

(curious what Mastodon clients are out there? there is [a very nice Google Sheet](https://docs.google.com/spreadsheets/d/1De5KRwqMIdwEryfoeBLARgxF7QgKkeOQBCilKuIdAXE/edit#gid=0) that tries to list out the various options across platforms, as well as the features they implement)

I am pretty varied in my own usage of the platform, and I wanted to take a look at which apps I've been using the most frequently.

Using Python with the Mastodon API (with the [Mastodon.py library](https://mastodonpy.readthedocs.io/en/stable/)), plus the lovely tools available in the Python ecosystem - in this case, Pandas and Matplotlib - we can quickly get a sense of where I've been spending my time, and where I've been experimenting.

![Chart showing the number of Toots posted via different Mastodon apps. Web, and Ivory for iOS, are the most-used](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ettbqftp1xyadajfow66.png)

Here's a quick overview of the code, cut down to the bare minimum:

```python
from mastodon import Mastodon
import pandas as pd
import matplotlib.pyplot as plt

API_KEY = "TOKEN"
mstdn_url = "https://my.instance"
user_id = "ID"

mstdn = Mastodon(access_token=API_KEY,
                 api_base_url=mstdn_url)

print("Getting All The Statuses ...")
# get only toots from this account (no boosts)
statuses = mstdn.account_statuses(user_id, exclude_reblogs=True)

apps_list = []

while statuses:
    statuses = mstdn.fetch_remaining(statuses)

    for s in statuses:
        apps_list.append(s["application"]["name"])
        break

print("Charting ...")

pd.Series(apps_list).value_counts(sort=False).plot(
    kind='barh', color='#563ACC', title="Mastodon client usage")
plt.savefig('toot-apps.pdf', bbox_inches='tight')

print('... done!')
```

Let's step through this:

- we import the Mastodon.py library, along with Pandas
- we set some variables to define our home Mastodon instance, and an API token (we created an app under the Development section in Mastodon settings)
- we call the API to grab all of the statuses (Toots) for our target user (this uses the Pagination feature available in Mastodon.py)
  - excluding the boosts, because these do not carry data about the application that was used to boost the Toot.
- for each status, we grab the name of the application used and add it to a list
- finally, we use Pandas and Matplotlib to create a horizontal bar chart, in the Mastodon purple colour, and save to a PDF.
   - there is plenty more I could do here, such as showing how different apps have been used at different times (simply by correlating with the date of usage)

Some data points: since I moved [my Mastodon presence](https://macaw.social/@andypiper) to my current instance (macaw.social) back in November, I've posted 1609 statuses, of which 954 were my own organic statuses rather than boosts. Half of those were posted using the default web UI. I've been using a variety of mobile apps, and started out mostly using MetaText on iOS - most recently, I've found myself using Ivory (which I've been using in TestFlight), but I really like some of the other options as well... Ice Cubes, Tusker and Mammoth are all great apps.

Of course, this is only showing the apps I've used the most often to actively post, and does not reflect time spent in apps or websites - I think that data would tell another story, but it would need to come from the devices I've been using, rather than from the API.

Just a quick post to summarise some of my own data - let me know what apps you're using, or what you're interested to do with the Mastodon API. 

See you in the #Fediverse!