I tried to find a way to use the rtweet package to perform a request to GET friendships/show from the Twitter REST API, in order to analyse the relationship between two users. However, I could not make it work (I did find lookup_friendships()
, but it does not do what I want). Is it possible to do that with rtweet, and if so, how?
Question posted in Twitter API
The official Twitter API documentation can be found here.
The official Twitter API documentation can be found here.
2
Answers
You might be able to use the
get_friends()
orget_followers()
functions.This feature has been added to rtweet, so there should be at least somewhat reasonable access to the “friendships/show” API via
lookup_friendships()
–and, bonus, it just got accepted in version0.6.0
now on CRAN now!Required inputs are
source
andtarget
(can be screen names or user IDs). If only one user is provided to eithersource
ortarget
, then any number of users–save Twitter API rate limits–can be passed in the other parameter.It’s also possible to specify more than one user in both
source
andtarget
parameters. However, if the length of both parameters is greater than 1, then the vectors must be of equal length.There hasn’t been a lot of time to test this yet. If you run into problems, try setting
parse = FALSE
. You’ll be left to wrangling the returned data by yourself, but it might help avoid errors in internal parsing.