Use the devtools R package to install from Github:
devtools::install_github('ThomasChln/mastodon')
A docker image with the package installed is also available
docker run -it thomaschln/mastodon
library(mastodon)
token = login('https://framapiaf.org/', '[email protected]', 'password')
post_status(token, 'Status text')
post_media(token, 'Image caption', file = '/home/user/file.png')
post_ggplot(token, 'Mastodon instances and users', ggplot_instances_info())
df = get_timeline(token, 'home')
df = get_timeline(token, 'local')
df = get_timeline(token, 'fediverse')
df = get_hashtag(token, 'rstats')
# Get more toots (default rate limit: 2 second sleep for each 20 toots)
df = get_timeline(token, 'fediverse', n = 30)
df = get_hashtag(token, 'mastodon', n = 30)
# Get toots before a specific id
df = get_timeline(token, 'fediverse', max_id = 26432)
df = get_hashtag(token, 'mastodon', max_id = 26432)
# Get hashtag only on local instance
df = get_hashtag(token, 'rstats', local = TRUE)
Search for a string or a username
df = search(token, 'thchln')
# don't resolve non-local accounts
df = search(token, 'thchln', local = TRUE)
df = search_username(token, 'thchln')
df = search_username(token, 'thchln', limit = 2)
Get an account or a toot by id
account = get_account(token, 475)
toot = get_status(token, 26432)
Number of users per instances
ggplot_instances_info()
Participation by hours
# Use a large server
token = login('https://mastodon.xyz/', '[email protected]', 'password')
df_toots = get_timeline(token, 'fed', n = 7e4)
toots_by_hours(df_toots) %>% ggplot_toots_by_hours(token$instance)
Participation of top 6 instances
toots_by_instances(df_toots) %>% ggplot_toots_by_instances(token$instance)
- Login, posts, and users per instances plot: pastebin script by @[email protected]
- Participation per instances plots: HTML-Rmd vignette by @[email protected]
This package is free and open source software, licensed under GPL-3.