I am trying to download the list of friends of a certain user on Twitter using rtweet.
If I try to download the friends list of a user who has less than 5000 friends, I get the expected result - a list of the user's friends.
However, if I try to download the friends list of a user who has more than 5000 friends I hit the API limit, so I have to use the page
parameter with the get_friends()
function as detailed here:
https://rtweet.info/reference/next_cursor.html
I am using @jimmyfallon as an example because he has more than 5000 Twitter friends.
f1 = get_friends("@jimmyfallon", retryonratelimit = TRUE)$user_id
Sys.sleep(60*15) # Sleep for 15mins
f2 = get_friends("@jimmyfallon", retryonratelimit = TRUE, page = next_cursor(f1))$user_id
The expected output of the code above would be that f1
contains the first 5000 friends and f2
contains the remaining lot of friends.
My actual result is f1
contains the first 5000 friends and f2
contains a 0x0 tibble (no data).
The strange thing is, sometimes I actually do get the expected output for f2
but most times it does not give the expected output.
I have tried increasing the sleep time to 30 minutes, used a different API key, removing the @ in get_friends()
and executing on a different network.
I am using R 3.6.1 and rtweet_0.6.9, running in RStudio.