Title: | Collecting and Analyzing Mastodon Data |
---|---|
Description: | An implementation of calls designed to collect and organize Mastodon data via its Application Program Interfaces (API), which can be found at the following URL: <https://docs.joinmastodon.org/>. |
Authors: | David Schoch [aut, cre] , Chung-hong Chan [aut] , Johannes Gruber [ctb] , Tim Schatto-Eckrodt [ctb] |
Maintainer: | David Schoch <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.5.9000 |
Built: | 2024-11-06 20:17:11 UTC |
Source: | https://github.com/gesistsa/rtoot |
Authenticate with a Mastodon instance
auth_setup( instance = NULL, type = NULL, name = NULL, path = NULL, clipboard = FALSE, verbose = TRUE, browser = TRUE )
auth_setup( instance = NULL, type = NULL, name = NULL, path = NULL, clipboard = FALSE, verbose = TRUE, browser = TRUE )
instance |
a public instance of Mastodon (e.g., mastodon.social). |
type |
Either "public" to create a public authentication or "user" to create authentication for your user (e.g., if you want to post from R or query your followers). |
name |
give the token a name, in case you want to store more than one. |
path |
path to store the token in. The default is to store tokens in the
path returned by |
clipboard |
logical, whether to export the token to the clipboard |
verbose |
logical whether to display messages |
browser |
if |
If either name
or path
are set to FALSE
, the token is only
returned and not saved. If you would like to save your token as an environment variable,
please set clipboard
to TRUE
. Your token will be copied to clipboard in the environment variable
format. Please paste it into your environment file, e.g. ".Renviron", and restart
your R session.
A bearer token
verify_credentials()
, convert_token_to_envvar()
## Not run: auth_setup("mastodon.social", "public") ## End(Not run)
## Not run: auth_setup("mastodon.social", "public") ## End(Not run)
Convert token to environment variable
convert_token_to_envvar(token, clipboard = TRUE, verbose = TRUE)
convert_token_to_envvar(token, clipboard = TRUE, verbose = TRUE)
token |
bearer token, either public or user level |
clipboard |
logical, whether to export the token to the clipboard |
verbose |
logical whether to display messages |
Token (in environment variable format), invisibily
## Not run: x <- auth_setup("mastodon.social", "public") envvar <- convert_token_to_envvar(x) envvar ## End(Not run)
## Not run: x <- auth_setup("mastodon.social", "public") envvar <- convert_token_to_envvar(x) envvar ## End(Not run)
get a bearer token for the mastodon api
create_token(client, type = "public", browser = TRUE)
create_token(client, type = "public", browser = TRUE)
client |
rtoot client object created with get_client |
type |
one of "public" or "user". See details |
browser |
if |
TBA
a mastodon bearer token
https://docs.joinmastodon.org/client/authorized/
Query the instance for a specific user
get_account(id, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE)
get_account(id, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE)
id |
character, Local ID of a user (this is not the username) |
instance |
character, the server name of the instance where the status is located. If |
token |
user bearer token (read from file by default) |
anonymous |
some API calls do not need a token. Setting anonymous to TRUE allows to make an anonymous call if possible. |
parse |
logical, if |
an account
## Not run: get_account("109302436954721982") ## End(Not run)
## Not run: get_account("109302436954721982") ## End(Not run)
Get blocks of user
get_account_blocks( max_id, since_id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
get_account_blocks( max_id, since_id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
max_id |
character or |
since_id |
character or |
limit |
integer, Maximum number of results to return |
token |
user bearer token (read from file by default) |
parse |
logical, if |
retryonratelimit |
If TRUE, and a rate limit is exhausted, will wait until it refreshes. Most Mastodon rate limits refresh every 5 minutes. If FALSE, and the rate limit is exceeded, the function will terminate early with a warning; you'll still get back all results received up to that point. |
verbose |
logical whether to display messages |
this functions needs a user level auth token. If limit>40, automatic pagination is used. You may get more results than requested.
tibble or list of blocked users
## Not run: # needs user level token get_account_blocks() ## End(Not run)
## Not run: # needs user level token get_account_blocks() ## End(Not run)
Get bookmarks of user
get_account_bookmarks( max_id, since_id, min_id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
get_account_bookmarks( max_id, since_id, min_id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
max_id |
character or |
since_id |
character or |
min_id |
character, Return results younger than this id |
limit |
integer, Maximum number of results to return |
token |
user bearer token (read from file by default) |
parse |
logical, if |
retryonratelimit |
If TRUE, and a rate limit is exhausted, will wait until it refreshes. Most Mastodon rate limits refresh every 5 minutes. If FALSE, and the rate limit is exceeded, the function will terminate early with a warning; you'll still get back all results received up to that point. |
verbose |
logical whether to display messages |
this functions needs a user level auth token. If limit>40, automatic pagination is used. You may get more results than requested.
bookmarked statuses
## Not run: get_account_followers("109302436954721982") ## End(Not run)
## Not run: get_account_followers("109302436954721982") ## End(Not run)
Get favourites of user
get_account_favourites( max_id, min_id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
get_account_favourites( max_id, min_id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
max_id |
character or |
min_id |
character, Return results younger than this id |
limit |
integer, Maximum number of results to return |
token |
user bearer token (read from file by default) |
parse |
logical, if |
retryonratelimit |
If TRUE, and a rate limit is exhausted, will wait until it refreshes. Most Mastodon rate limits refresh every 5 minutes. If FALSE, and the rate limit is exceeded, the function will terminate early with a warning; you'll still get back all results received up to that point. |
verbose |
logical whether to display messages |
this functions needs a user level auth token. If limit>40, automatic pagination is used. You may get more results than requested.
tibble or list of favourited statuses
## Not run: # needs user level token get_account_favourites() ## End(Not run)
## Not run: # needs user level token get_account_favourites() ## End(Not run)
Get featured tags of a user
get_account_featured_tags(id, token = NULL, parse = TRUE)
get_account_featured_tags(id, token = NULL, parse = TRUE)
id |
character, local ID of a user (this is not the username) |
token |
user bearer token (read from file by default) |
parse |
logical, if |
this functions needs a user level auth token
tibble or list of featured_tags
## Not run: get_account_featured_tags("109302436954721982") ## End(Not run)
## Not run: get_account_featured_tags("109302436954721982") ## End(Not run)
Get followers of a user
get_account_followers( id, max_id, since_id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
get_account_followers( id, max_id, since_id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
id |
character, local ID of a user (this is not the username) |
max_id |
character or |
since_id |
character or |
limit |
integer, maximum number of results to return. Defaults to 40. |
token |
user bearer token (read from file by default) |
parse |
logical, if |
retryonratelimit |
If TRUE, and a rate limit is exhausted, will wait until it refreshes. Most Mastodon rate limits refresh every 5 minutes. If FALSE, and the rate limit is exceeded, the function will terminate early with a warning; you'll still get back all results received up to that point. |
verbose |
logical whether to display messages |
this functions needs a user level auth token. If limit>40, automatic pagination is used. You may get more results than requested.
tibble or list of followers
## Not run: get_account_followers("109302436954721982") ## End(Not run)
## Not run: get_account_followers("109302436954721982") ## End(Not run)
Get accounts a user follows
get_account_following( id, max_id, since_id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
get_account_following( id, max_id, since_id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
id |
character, local ID of a user (this is not the username) |
max_id |
character or |
since_id |
character or |
limit |
integer, Maximum number of results to return |
token |
user bearer token (read from file by default) |
parse |
logical, if |
retryonratelimit |
If TRUE, and a rate limit is exhausted, will wait until it refreshes. Most Mastodon rate limits refresh every 5 minutes. If FALSE, and the rate limit is exceeded, the function will terminate early with a warning; you'll still get back all results received up to that point. |
verbose |
logical whether to display messages |
this functions needs a user level auth token. If limit>40, automatic pagination is used. You may get more results than requested.
tibble or list of accounts a user follows
## Not run: get_account_following("109302436954721982") ## End(Not run)
## Not run: get_account_following("109302436954721982") ## End(Not run)
Get lists containing the user
get_account_lists(id, token = NULL, parse = TRUE)
get_account_lists(id, token = NULL, parse = TRUE)
id |
character, local ID of a user (this is not the username) |
token |
user bearer token (read from file by default) |
parse |
logical, if |
this functions needs a user level auth token
tibble or list of lists
## Not run: get_account_lists("109302436954721982") ## End(Not run)
## Not run: get_account_lists("109302436954721982") ## End(Not run)
Get mutes of user
get_account_mutes( max_id, since_id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
get_account_mutes( max_id, since_id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
max_id |
character or |
since_id |
character or |
limit |
integer, Maximum number of results to return |
token |
user bearer token (read from file by default) |
parse |
logical, if |
retryonratelimit |
If TRUE, and a rate limit is exhausted, will wait until it refreshes. Most Mastodon rate limits refresh every 5 minutes. If FALSE, and the rate limit is exceeded, the function will terminate early with a warning; you'll still get back all results received up to that point. |
verbose |
logical whether to display messages |
this functions needs a user level auth token. If limit>40, automatic pagination is used. You may get more results than requested.
tibble or list of muted users
## Not run: # needs user level token get_account_mutes() ## End(Not run)
## Not run: # needs user level token get_account_mutes() ## End(Not run)
Find out whether a given account is followed, blocked, muted, etc.
get_account_relationships(ids, token = NULL, parse = TRUE)
get_account_relationships(ids, token = NULL, parse = TRUE)
ids |
vector of account ids |
token |
user bearer token (read from file by default) |
parse |
logical, if |
this functions needs a user level auth token
tibble or list of relationships
## Not run: fol <- get_account_followers("109302436954721982") get_account_relationships(fol$id) ## End(Not run)
## Not run: fol <- get_account_followers("109302436954721982") get_account_relationships(fol$id) ## End(Not run)
Get statuses from a user
get_account_statuses( id, max_id, since_id, min_id, limit = 20L, exclude_reblogs = FALSE, hashtag, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
get_account_statuses( id, max_id, since_id, min_id, limit = 20L, exclude_reblogs = FALSE, hashtag, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
id |
character, local ID of a user (this is not the username) |
max_id |
character or |
since_id |
character or |
min_id |
character or |
limit |
integer, Maximum number of results to return |
exclude_reblogs |
logical, Whether to filter out boosts from the response. |
hashtag |
character, filter for statuses using a specific hashtag. |
instance |
character, the server name of the instance where the status is located. If |
token |
user bearer token (read from file by default) |
anonymous |
some API calls do not need a token. Setting anonymous to TRUE allows to make an anonymous call if possible. |
parse |
logical, if |
retryonratelimit |
If TRUE, and a rate limit is exhausted, will wait until it refreshes. Most Mastodon rate limits refresh every 5 minutes. If FALSE, and the rate limit is exceeded, the function will terminate early with a warning; you'll still get back all results received up to that point. |
verbose |
logical whether to display messages |
For anonymous calls only public statuses are returned. If a user token is supplied also private statuses the user is authorized to see are returned
tibble or list of statuses
## Not run: get_account_statuses("109302436954721982") ## End(Not run)
## Not run: get_account_statuses("109302436954721982") ## End(Not run)
register a mastodon client
get_client(instance = "mastodon.social")
get_client(instance = "mastodon.social")
instance |
server name |
an rtoot client object
https://docs.joinmastodon.org/client/token/#creating-our-application
Query the instance for information about the context of a specific status. A context contains statuses above and below a status in a thread.
get_context(id, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE)
get_context(id, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE)
id |
character, local ID of a status in the database |
instance |
character, the server name of the instance where the status is located. If |
token |
user bearer token (read from file by default) |
anonymous |
some API calls do not need a token. Setting anonymous to TRUE allows to make an anonymous call if possible. |
parse |
logical, if |
context of a toot as tibble or list
## Not run: get_context(id = "109294719267373593", instance = "mastodon.social") ## End(Not run)
## Not run: get_context(id = "109294719267373593", instance = "mastodon.social") ## End(Not run)
Get a list of fediverse servers
get_fedi_instances(token = NA, n = 20, ...)
get_fedi_instances(token = NA, n = 20, ...)
token |
token from instances.social (this is different from your Mastodon token!) |
n |
number of servers to show |
... |
additional parameters for the instances.social API. See https://instances.social/api/doc/ |
This function uses the API at instances.social and needs a separate token. Results are sorted by number of users
tibble of fediverse instances
## Not run: get_fedi_instances(n = 5) ## End(Not run)
## Not run: get_fedi_instances(n = 5) ## End(Not run)
Get various information about a specific instance
get_instance_general(instance = NULL, token = NULL, anonymous = TRUE) get_instance_peers(instance = NULL, token = NULL, anonymous = TRUE) get_instance_activity(instance = NULL, token = NULL, anonymous = TRUE) get_instance_emoji(instance = NULL, token = NULL, anonymous = TRUE) get_instance_directory( instance = NULL, token = NULL, offset = 0, limit = 40, order = "active", local = FALSE, anonymous = TRUE, parse = TRUE ) get_instance_trends( instance = NULL, token = NULL, limit = 10, anonymous = TRUE ) get_instance_rules(instance = NULL, token = NULL, anonymous = FALSE) get_instance_blocks(instance = NULL, token = NULL, anonymous = TRUE)
get_instance_general(instance = NULL, token = NULL, anonymous = TRUE) get_instance_peers(instance = NULL, token = NULL, anonymous = TRUE) get_instance_activity(instance = NULL, token = NULL, anonymous = TRUE) get_instance_emoji(instance = NULL, token = NULL, anonymous = TRUE) get_instance_directory( instance = NULL, token = NULL, offset = 0, limit = 40, order = "active", local = FALSE, anonymous = TRUE, parse = TRUE ) get_instance_trends( instance = NULL, token = NULL, limit = 10, anonymous = TRUE ) get_instance_rules(instance = NULL, token = NULL, anonymous = FALSE) get_instance_blocks(instance = NULL, token = NULL, anonymous = TRUE)
instance |
character, the server name of the instance where the status is located. If |
token |
user bearer token (read from file by default) |
anonymous |
logical, should the API call be made anonymously? Defaults to TRUE but some instances might need authentication here |
offset |
How many accounts to skip before returning results. Default 0. |
limit |
integer, Maximum number of results to return |
order |
'active' to sort by most recently posted statuses (default) or 'new' to sort by most recently created profiles. |
local |
logical, show only local accounts? |
parse |
logical, if |
Returns general information about the instance
Returns the peers of an instance
Shows the weekly activity of the instance (3 months)
Lists custom emojis available on the instance
A directory of profiles that the instance is aware of
Tags that are being used more frequently within the past week
Prints the rules of an instance
List of domains that are blocked by an instance.
instance details as list or tibble depending on call function
## Not run: get_instance_general("mastodon.social") get_instance_activity("mastodon.social") get_instance_emoji("mastodon.social") get_instance_peers("mastodon.social") get_instance_directory("mastodon.social",limit = 2) ## End(Not run)
## Not run: get_instance_general("mastodon.social") get_instance_activity("mastodon.social") get_instance_emoji("mastodon.social") get_instance_peers("mastodon.social") get_instance_directory("mastodon.social",limit = 2) ## End(Not run)
View accounts in a list
get_list_accounts( id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
get_list_accounts( id, limit = 40L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
id |
character, id of the list |
limit |
integer, number of records to return |
token |
bearer token created with create_token |
parse |
logical, if |
retryonratelimit |
If TRUE, and a rate limit is exhausted, will wait until it refreshes. Most Mastodon rate limits refresh every 5 minutes. If FALSE, and the rate limit is exceeded, the function will terminate early with a warning; you'll still get back all results received up to that point. |
verbose |
logical, whether to display messages |
a tibble or list of accounts
## Not run: get_list_accounts(id = "test") ## End(Not run)
## Not run: get_list_accounts(id = "test") ## End(Not run)
Fetch all lists the user owns
get_lists(id = "", token = NULL, parse = TRUE)
get_lists(id = "", token = NULL, parse = TRUE)
id |
character, either the id of a list to return or "" to show all lists |
token |
bearer token created with create_token |
parse |
logical, if |
a tibble or list of lists owned by the user
## Not run: get_lists() ## End(Not run)
## Not run: get_lists() ## End(Not run)
View a polls attached to statuses. To discover poll ID, you will need to use get_status()
and look into the poll
.
get_poll(id, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE)
get_poll(id, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE)
id |
character, ID of the poll in the database |
instance |
character, the server name of the instance where the status is located. If |
token |
user bearer token (read from file by default) |
anonymous |
some API calls do not need a token. Setting anonymous to TRUE allows to make an anonymous call if possible. |
parse |
logical, if |
a poll
## Not run: get_poll(id = "105976") ## End(Not run)
## Not run: get_poll(id = "105976") ## End(Not run)
Query the instance for information about a specific status. get_status returns complete information of a status. get_reblogged_by returns who boosted a given status. get_favourited_by returns who favourited a given status.
get_status(id, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE) get_reblogged_by( id, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE ) get_favourited_by( id, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE )
get_status(id, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE) get_reblogged_by( id, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE ) get_favourited_by( id, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE )
id |
character, local ID of a status in the database |
instance |
character, the server name of the instance where the status is located. If |
token |
user bearer token (read from file by default) |
anonymous |
some API calls do not need a token. Setting anonymous to TRUE allows to make an anonymous call if possible. |
parse |
logical, if |
a status or a list of users
## Not run: get_status(id = "109326579599502650") get_reblogged_by(id = "109326579599502650") get_favourited_by(id = "109326579599502650") ## End(Not run)
## Not run: get_status(id = "109326579599502650") get_reblogged_by(id = "109326579599502650") get_favourited_by(id = "109326579599502650") ## End(Not run)
Query the instance for the timeline of a specific hashtag
get_timeline_hashtag( hashtag = "rstats", local = FALSE, only_media = FALSE, max_id, since_id, min_id, limit = 20L, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
get_timeline_hashtag( hashtag = "rstats", local = FALSE, only_media = FALSE, max_id, since_id, min_id, limit = 20L, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
hashtag |
character, Content of a #hashtag. The hash is optional |
local |
logical, Show only local statuses? |
only_media |
logical, Show only statuses with media attached? |
max_id |
character or |
since_id |
character or |
min_id |
character or |
limit |
integer, Maximum number of results to return |
instance |
character, the server name of the instance where the status is located. If |
token |
user bearer token (read from file by default) |
anonymous |
some API calls do not need a token. Setting anonymous to TRUE allows to make an anonymous call if possible. |
parse |
logical, if |
retryonratelimit |
If TRUE, and a rate limit is exhausted, will wait until it refreshes. Most Mastodon rate limits refresh every 5 minutes. If FALSE, and the rate limit is exceeded, the function will terminate early with a warning; you'll still get back all results received up to that point. |
verbose |
logical whether to display messages |
max_id
, since_id
, and min_id
can either be character or POSIXct
(date time). If it is POSXIct
, it will be converted to the so-called snowflake ID.
statuses
https://docs.joinmastodon.org/methods/timelines/
## Not run: get_timeline_hashtag(hashtag = "#ichbinhanna") ## anonymously get_timeline_hashtag(hashtag = "ichbinhanna", instance = "mastodon.social", anonymous = TRUE) ## Search for toots by date get_timeline_hashtag(hashtag = "ichbinhanna", instance = "mastodon.social", anonymous = TRUE, max_id = as.POSIXct("2024-03-01")) ## End(Not run)
## Not run: get_timeline_hashtag(hashtag = "#ichbinhanna") ## anonymously get_timeline_hashtag(hashtag = "ichbinhanna", instance = "mastodon.social", anonymous = TRUE) ## Search for toots by date get_timeline_hashtag(hashtag = "ichbinhanna", instance = "mastodon.social", anonymous = TRUE, max_id = as.POSIXct("2024-03-01")) ## End(Not run)
Query the instance for the timeline from either followed users or a specific list. These functions can only be called with a user token from create_token()
.
get_timeline_home( local = FALSE, max_id, since_id, min_id, limit = 20L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE ) get_timeline_list( list_id, max_id, since_id, min_id, limit = 20L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
get_timeline_home( local = FALSE, max_id, since_id, min_id, limit = 20L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE ) get_timeline_list( list_id, max_id, since_id, min_id, limit = 20L, token = NULL, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
local |
logical, Show only local statuses? |
max_id |
character or |
since_id |
character or |
min_id |
character or |
limit |
integer, Maximum number of results to return |
token |
user bearer token (read from file by default) |
parse |
logical, if |
retryonratelimit |
If TRUE, and a rate limit is exhausted, will wait until it refreshes. Most Mastodon rate limits refresh every 5 minutes. If FALSE, and the rate limit is exceeded, the function will terminate early with a warning; you'll still get back all results received up to that point. |
verbose |
logical whether to display messages |
list_id |
character, Local ID of the list in the database. |
max_id
, since_id
, and min_id
can either be character or POSIXct
(date time). If it is POSXIct
, it will be converted to the so-called snowflake ID.
statuses
https://docs.joinmastodon.org/methods/timelines/
## Not run: get_timeline_home() ## End(Not run) ## Not run: get_timeline_list("<listid>") ## End(Not run)
## Not run: get_timeline_home() ## End(Not run) ## Not run: get_timeline_list("<listid>") ## End(Not run)
Query the instance for the public timeline
get_timeline_public( local = FALSE, remote = FALSE, only_media = FALSE, max_id, since_id, min_id, limit = 20L, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
get_timeline_public( local = FALSE, remote = FALSE, only_media = FALSE, max_id, since_id, min_id, limit = 20L, instance = NULL, token = NULL, anonymous = FALSE, parse = TRUE, retryonratelimit = TRUE, verbose = TRUE )
local |
logical, Show only local statuses? |
remote |
logical, Show only remote statuses? |
only_media |
logical, Show only statuses with media attached? |
max_id |
character or |
since_id |
character or |
min_id |
character or |
limit |
integer, Maximum number of results to return |
instance |
character, the server name of the instance where the status is located. If |
token |
user bearer token (read from file by default) |
anonymous |
some API calls do not need a token. Setting anonymous to TRUE allows to make an anonymous call if possible. |
parse |
logical, if |
retryonratelimit |
If TRUE, and a rate limit is exhausted, will wait until it refreshes. Most Mastodon rate limits refresh every 5 minutes. If FALSE, and the rate limit is exceeded, the function will terminate early with a warning; you'll still get back all results received up to that point. |
verbose |
logical whether to display messages |
max_id
, since_id
, and min_id
can either be character or POSIXct
(date time). If it is POSXIct
, it will be converted to the so-called snowflake ID.
statuses
https://docs.joinmastodon.org/methods/timelines/
## Not run: ## as tibble get_timeline_public() ## as list get_timeline_public(parse = FALSE) ## End(Not run)
## Not run: ## as tibble get_timeline_public() ## as list get_timeline_public(parse = FALSE) ## End(Not run)
Converts Mastodon stream data (JSON file) into a parsed tibble.
parse_stream(path)
parse_stream(path)
path |
Character, name of JSON file with data collected by any stream_timeline function. |
The stream sometimes returns invalid lines of json. These are automatically skipped. Parsing can be slow if your json contains a large amount of statuses
a tibble of statuses
stream_timeline_public()
, stream_timeline_hashtag()
,stream_timeline_list()
## Not run: stream_timeline_public(1, file_name = "stream.json") parse_stream("stream.json") ## End(Not run)
## Not run: stream_timeline_public(1, file_name = "stream.json") parse_stream("stream.json") ## End(Not run)
Add accounts to a list
post_list_accounts(id, account_ids, token = NULL, verbose = TRUE)
post_list_accounts(id, account_ids, token = NULL, verbose = TRUE)
id |
character, id of the list |
account_ids |
ids of accounts to add (this is not the username) |
token |
user bearer token (read from file by default) |
verbose |
logical whether to display messages |
no return value, called for site effects
## Not run: # add some accounts to a list post_list_create(id = "1234", account_ids = c(1001, 1002)) ## End(Not run)
## Not run: # add some accounts to a list post_list_create(id = "1234", account_ids = c(1001, 1002)) ## End(Not run)
Create a list
post_list_create(title, replies_policy = "list", token = NULL, verbose = TRUE)
post_list_create(title, replies_policy = "list", token = NULL, verbose = TRUE)
title |
character, The title of the list to be created |
replies_policy |
character, One of "followed", "list", or "none". Defaults to "list". |
token |
user bearer token (read from file by default) |
verbose |
logical whether to display messages |
no return value, called for site effects
## Not run: # create a list post_list_create(title = "test") ## End(Not run)
## Not run: # create a list post_list_create(title = "test") ## End(Not run)
Perform actions on a status
post_status(id, action = "favourite", token = NULL, verbose = TRUE)
post_status(id, action = "favourite", token = NULL, verbose = TRUE)
id |
character, status id to perform the action on |
action |
character, one of "(un)favourite","(un)reblog","(un)bookmark" |
token |
user bearer token (read from file by default) |
verbose |
logical whether to display messages |
no return value, called for site effects
## Not run: # favourite a status post_status("xxxxxx", action = "favourite") # unfavourite a status post_status("xxxxxx", action = "unfavourite") ## End(Not run)
## Not run: # favourite a status post_status("xxxxxx", action = "favourite") # unfavourite a status post_status("xxxxxx", action = "unfavourite") ## End(Not run)
Be aware that excessive automated posting is frowned upon (or even against the ToS) in many instances. Make sure to check the ToS of your instance and be mindful when using this function.
post_toot( status = "my first rtoot #rstats", media = NULL, alt_text = NULL, token = NULL, in_reply_to_id = NULL, sensitive = FALSE, spoiler_text = NULL, visibility = "public", scheduled_at = NULL, language = NULL, verbose = TRUE )
post_toot( status = "my first rtoot #rstats", media = NULL, alt_text = NULL, token = NULL, in_reply_to_id = NULL, sensitive = FALSE, spoiler_text = NULL, visibility = "public", scheduled_at = NULL, language = NULL, verbose = TRUE )
status |
character, toot status. Must be 500 characters or less. |
media |
character, path to media to add to post |
alt_text |
character, a plain-text description of the media, for accessibility purposes. |
token |
user bearer token (read from file by default) |
in_reply_to_id |
character, ID of the status being replied to, if status is a reply |
sensitive |
logical, mark status and attached media as sensitive? |
spoiler_text |
character, text to be shown as a warning or subject before the actual content. Statuses are generally collapsed behind this field. |
visibility |
character, Visibility of the posted status. One of public (default), unlisted, private, direct. |
scheduled_at |
ISO 8601 Datetime at which to schedule a status. Must be at least 5 minutes in the future. |
language |
ISO 639 language code for this status. |
verbose |
logical whether to display messages |
no return value, called for site effects
## Not run: # post a simple status post_toot("my first rtoot #rstats") # post a media file with alt text post_toot("look at this pic", media = "path/to/image", alt_text = "describe image") ## End(Not run)
## Not run: # post a simple status post_toot("my first rtoot #rstats") # post a media file with alt text post_toot("look at this pic", media = "path/to/image", alt_text = "describe image") ## End(Not run)
Perform actions on an account
post_user(id, action = "follow", comment = "", token = NULL, verbose = TRUE)
post_user(id, action = "follow", comment = "", token = NULL, verbose = TRUE)
id |
character, user id to perform the action on |
action |
character, one of "(un)follow","(un)block", "(un)mute", "(un)pin","note" |
comment |
character (if action="note"), The comment to be set on that user. Provide an empty string or leave out this parameter to clear the currently set note. |
token |
user bearer token (read from file by default) |
verbose |
logical whether to display messages |
no return value, called for site effects
## Not run: # follow a user post_user("xxxxxx", action = "follow") # unfollow a user post_user("xxxxxx", action = "unfollow") ## End(Not run)
## Not run: # follow a user post_user("xxxxxx", action = "follow") # unfollow a user post_user("xxxxxx", action = "unfollow") ## End(Not run)
This is a minimalistic interface for querying the Mastodon API. This function is for advanced users who want to query the Mastodon API for endpoints that the R functions are not yet implemented. Please also note that the API responses will not be parsed as tibble. Refer to the official API documentation for endpoints and parameters.
rtoot( endpoint, ..., params = list(), token = NULL, instance = NULL, anonymous = FALSE )
rtoot( endpoint, ..., params = list(), token = NULL, instance = NULL, anonymous = FALSE )
endpoint |
character, a Mastodon API endpoint. Currently, only endpoints using GET are supported |
... |
Name-value pairs giving API parameters. |
params |
list, API parameters to be submitted |
token |
user bearer token (read from file by default) |
instance |
character, the server name of the instance where the status is located. If |
anonymous |
some API calls do not need a token. Setting anonymous to TRUE allows to make an anonymous call if possible. |
a list
https://docs.joinmastodon.org/methods/
## Not run: rtoot(endpoint = "api/v1/notifications") rtoot(endpoint = "api/v1/notifications", limit = 8) ## same rtoot(endpoint = "api/v1/notifications", params = list(limit = 8)) rtoot(endpoint = "api/v1/followed_tags") ## reimplement `get_timeline_public` rtoot(endpoint = "api/v1/timelines/public", instance = "emacs.ch", local = TRUE, anonymous = TRUE) ## End(Not run)
## Not run: rtoot(endpoint = "api/v1/notifications") rtoot(endpoint = "api/v1/notifications", limit = 8) ## same rtoot(endpoint = "api/v1/notifications", params = list(limit = 8)) rtoot(endpoint = "api/v1/followed_tags") ## reimplement `get_timeline_public` rtoot(endpoint = "api/v1/timelines/public", instance = "emacs.ch", local = TRUE, anonymous = TRUE) ## End(Not run)
save a bearer token to file
save_auth_rtoot(token, name = NULL, path = NULL)
save_auth_rtoot(token, name = NULL, path = NULL)
token |
bearer token created with create_token |
name |
A file name (if you want to store more than one token). |
path |
A path where the token is stored. |
Search the instance for a specific user
search_accounts( query, limit = 40, token = NULL, anonymous = FALSE, parse = TRUE )
search_accounts( query, limit = 40, token = NULL, anonymous = FALSE, parse = TRUE )
query |
character, search string |
limit |
number of search results to return. Defaults to 40 |
token |
user bearer token (read from file by default) |
anonymous |
some API calls do not need a token. Setting anonymous to TRUE allows to make an anonymous call if possible. |
parse |
logical, if |
a tibble ir list of accounts
## Not run: search_accounts("schochastics") ## End(Not run)
## Not run: search_accounts("schochastics") ## End(Not run)
Collect live streams of Mastodon data
stream_timeline_public( timeout = 30, local = FALSE, file_name = NULL, append = TRUE, instance = NULL, token = NULL, anonymous = FALSE, verbose = TRUE ) stream_timeline_hashtag( hashtag = "rstats", timeout = 30, local = FALSE, file_name = NULL, append = TRUE, instance = NULL, token = NULL, anonymous = FALSE, verbose = TRUE ) stream_timeline_list( list_id, timeout = 30, file_name = NULL, append = TRUE, instance = NULL, token = NULL, anonymous = FALSE, verbose = TRUE )
stream_timeline_public( timeout = 30, local = FALSE, file_name = NULL, append = TRUE, instance = NULL, token = NULL, anonymous = FALSE, verbose = TRUE ) stream_timeline_hashtag( hashtag = "rstats", timeout = 30, local = FALSE, file_name = NULL, append = TRUE, instance = NULL, token = NULL, anonymous = FALSE, verbose = TRUE ) stream_timeline_list( list_id, timeout = 30, file_name = NULL, append = TRUE, instance = NULL, token = NULL, anonymous = FALSE, verbose = TRUE )
timeout |
Integer, Number of seconds to stream toots for. Stream indefinitely with timeout = Inf. The stream can be interrupted at any time, and file_name will still be a valid file. |
local |
logical, Show only local statuses (either statuses from your instance or the one provided in |
file_name |
character, name of file. If not specified, will write to a temporary file stream_toots*.json. |
append |
logical, if TRUE will append to the end of file_name; if FALSE, will overwrite. |
instance |
character, the server name of the instance where the status is located. If |
token |
user bearer token (read from file by default) |
anonymous |
logical, should the API call be made anonymously? Defaults to TRUE but some instances might need authentication here |
verbose |
logical whether to display messages |
hashtag |
character, hashtag to stream |
list_id |
character, id of list to stream |
stream all public statuses on any instance
stream all statuses containing a specific hashtag
stream the statuses of a list
does not return anything. Statuses are written to file
## Not run: # stream public timeline for 30 seconds stream_timeline_public(timeout = 30, file_name = "public.json") # stream timeline of mastodon.social for 30 seconds stream_timeline_public( timeout = 30, local = TRUE, instance = "mastodon.social", file_name = "social.json" ) # stream hashtag timeline for 30 seconds stream_timeline_hashtag("rstats", timeout = 30, file_name = "rstats_public.json") # stream hashtag timeline of mastodon.social for 30 seconds stream_timeline_hashtag("rstats", timeout = 30, local = TRUE, instance = "fosstodon.org", file_name = "rstats_foss.json" ) # json files can be parsed with parse_stream() parse_stream("rstats_foss.json") ## End(Not run)
## Not run: # stream public timeline for 30 seconds stream_timeline_public(timeout = 30, file_name = "public.json") # stream timeline of mastodon.social for 30 seconds stream_timeline_public( timeout = 30, local = TRUE, instance = "mastodon.social", file_name = "social.json" ) # stream hashtag timeline for 30 seconds stream_timeline_hashtag("rstats", timeout = 30, file_name = "rstats_public.json") # stream hashtag timeline of mastodon.social for 30 seconds stream_timeline_hashtag("rstats", timeout = 30, local = TRUE, instance = "fosstodon.org", file_name = "rstats_foss.json" ) # json files can be parsed with parse_stream() parse_stream("rstats_foss.json") ## End(Not run)
Verify mastodon credentials
verify_credentials(token, verbose = TRUE) verify_envvar(verbose = TRUE)
verify_credentials(token, verbose = TRUE) verify_envvar(verbose = TRUE)
token |
bearer token, either public or user level |
verbose |
logical whether to display messages |
If you have created your token as an environment variable, use verify_envvar
to verify your token.
Raise an error if the token is not valid. Return the response from the verification API invisibly otherwise.
## Not run: # read a token from a file verify_credentials(token) ## End(Not run)
## Not run: # read a token from a file verify_credentials(token) ## End(Not run)