Abstract

The software reviewed is presented in https://doi.org/10.1177/20501579231176678
Relevance
Mastodon experienced a recent surge in user numbers following the takeover of Twitter by Elon Musk. While the number of active users is decreasing again, Mastodon is predicted to stay a larger platform than before (Hoover, 2023). Independent of its long-term success, the events of 2022/2023 make Mastodon a unique case study for scholars to investigate the phenomenon of large-scale user migration. Mastodon's unique characteristics, on its own and in contrast to Twitter, make it a curious object of interest for research on social networks, instances, and cross-instance dynamics (Cava et al., 2022; Zignani et al., 2018, 2019).
rtoot
The R package rtoot by Schoch and Chan allows interaction with the Mastodon Application Programming Interface (API). It provides functions to request and receive authentication tokens by the Mastodon API and to retrieve information on an instance, user, and status level. The documentation guides well through its functionality. The package is accessible and transparent by being distributed through the Comprehensive R Archive Network (CRAN) and published on GitHub (Schoch, 2023; Schoch & Chan, 2023).
Alternatives
As an alternative to rtoot, researchers can query Mastodon's REpresentational State Transfer (REST) API (type of an application programming interface for cross-application communication: for example, between a programming environment and the Mastodon server) directly with R or other programming languages, which requires users to have knowledge about REST APIs (Mastodon, 2023). This might not be the case for every scholar from communications science or adjacent fields who wants to research data from Mastodon. Interacting with the Mastodon API through an R package that lets the user stay in known R entities (e.g., functions and data frames) increases the accessibility of Mastodon data.
Listed on the Mastodon website and only published via GitHub is the R package mastodon (Chin, 2022). This package has not been updated since 2017. mastodon is not listed on the CRAN and is thereby limited regarding documentation, security, and transparency. It provides only basic functionality compared to rtoot. Thereby, rtoot is—by the time of publishing—the only actively maintained R package that allows convenient interaction with the Mastodon API.
Functionality
Its decentralized nature is a critical aspect of Mastodon that differentiates the platform from centralized competitors such as Twitter. With each instance being a dedicated social network within the broader universe of Mastodon, separate instance authentications are needed. Rtoot provides the convenient auth_setup() function that guides the inexperienced user through receiving an access token (user or public level). The functionalities include the possibility to load different access tokens into the current R environment and thereby facilitate automated cross-instance data collection. The data retrieval functions allow data collection from instances, the different types of timelines (public, hashtag, home; instance only or platform-wide), and user accounts. Additionally, rtoot facilitates posting text and media content. This function might be of interest to field experiments in the digital space.
Depending on the function or privacy status of the data, either of two authentication levels is needed: public or user. The reference manual indicates which authentication level is required for specific functions and references the respective Mastodon API documentation that is even more detailed (Schoch et al., 2023). Given the importance of the type of access token for the ability to retrieve certain types of data, it would be helpful to provide an overview regarding the functionality of every function depending on the access level in a less hidden spot than the rtoot CRAN reference manual (e.g., GitHub documentation/Wiki).
rtoot also implements the streaming functionality of the Mastodon API. The data are written directly to a JavaScript Object Notation (JSON) file, which can be converted to an R data frame with the parse_stream() function. It also provides the rtoot() function, which allows making REST API queries to new or not yet implemented endpoints. The functions are named logically and clearly, allowing us to understand their purpose and functionality.
The authors additionally provide auxiliary R functions that cope with the more complex data structures retrieved by the API (lists within the data frame). This is particularly helpful for scholars that do not yet have many R experiences.
The described functions allow researchers to interact with the Mastodon API while staying in the R environment and its native data structures. Thereby, rtoot contributes to the accessibility of digital trace data originating from Mastodon. The posting and streaming capabilities allow for more novel research designs.
Example
To showcase the functionality of
A fair amount of content was posted through mobile applications, but the naive classification procedure results in many applications being summarized in Other (see Figure 1). Screening those applications manually, they seem to consist of mobile apps that do not contain the string “iOS” or “android,” and bot-like services not containing the string “bot.”

Number of posts per application category.
Documentation
A thorough documentation is available. Besides introduction guides, all functions are documented within the reference manual published on the CRAN (Schoch et al., 2023). Given that scholars using rtoot can be expected to have the contextual knowledge about Mastodon's decentralized nature, the documentation guiding the authentication procedures is sufficient.
An introduction to showcase essential functions and a detailed description of the more complex procedures that rtoot provides (authentication and live streaming) exists. The reference manual on the CRAN offers additional information on every function in the package.
Summary
Given the relevance of Mastodon for research, the contribution by rtoot to make the platform's data more accessible is vital. It already provides all basic functionalities to retrieve the standard data points of interest (instance, user, and status level) and provides added functionality for more sophisticated methodological setups (live stream and posting).
The package does a good job of facilitating multiple authentication tokens to cope with the decentralized nature of Mastodon. To enhance the user experience, a concise overview is desirable that informs what function works to what extent with what type of access token (user and public). Besides that, the package has excellent documentation.
rtoot is a well-written and well-structured package that provides extensive functionality that outshines the mastodon package and the direct interaction with the API, making data for a relevant (mobile) platform more accessible.
Footnotes
Funding
The author received no financial support for the research, authorship, and/or publication of this article.
Author biography
Lion Wedel is a doctoral researcher at the Weizenbaum Institute for the Networked Society. His research is focusing on computational methods and information dynamics on social media platforms.
