safe_get_followers: Safely get follower list of Twitter users

Description Usage Arguments Details Value

View source: R/api-calls.R

Description

safe_get_followers() is a drop-in replacement for rtweet::get_followers() that automatically respects Twitter API rate limits and coordinates use of multiple Twitter access tokens that have been registered with register_token(). At the moment you can only request the friends list of 15 or fewer users in a single call.

Usage

1
safe_get_followers(users, n = 5000, page = -1, verbose = FALSE, attempts = 5)

Arguments

n

Number of followers to return. Defaults to 5000, which is the max number of followers returned by a single API request. Twitter allows up to 15 of these requests every 15 minutes, which means 75,000 is the max number of followers to return without waiting for the rate limit to reset. If this number exceeds either 75,000 or the remaining number of possible requests for a given token, then the returned object will only return what it can (less than n) unless retryonratelimit is set to true.

page

Default page = -1 specifies first page of JSON results. Other pages specified via cursor values supplied by Twitter API response object. If parse = TRUE then the cursor value can be extracted from the return object by using the next_cursor function.

verbose

Logical indicating whether or not to print messages. Only relevant if retryonratelimit = TRUE. Defaults to TRUE, prints sleep times and followers gathered counts.

attempts

How many times should we attempt to access the Twitter API before giving up? Defaults to 5.

Details

If no tokens have been registered with socialsampler, safe_get_followers() will look for a token registered with rtweet and use that token instead, again automatically respecting rate limits. If no tokens have been registered with either socialsampler or rtweet, you'll get an error.

Value

An edgelist with columns:


alexpghayes/socialsampler documentation built on Jan. 3, 2022, 6:54 p.m.