Search code examples
rtwitterrate-limiting

Avoiding twitter's rate limiting


When I do the following :

library(twitteR)
library("ROAuth")

consumer_key <- ''
consumer_secret <- ''
access_token <- ''
access_token_secret <- ''

setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_token_secret)

potus_user <- twitteR::getUser("potus")
followers_potus <- potus_user$getFollowerIDs()

I get an array with 70000 entries, and the following message :

Warning message:
In twInterfaceObj$doAPICall(cmd, params, method, ...) :
  Rate limit encountered & retry limit reached - returning partial results

I get what it's telling me, I'm asking for too much.

Is there, for instance, a way to loop on the getFollowerIDs() method and get the 70000 next followers once the rate limiting is erased ?


Solution

  • Have you created multiple credentials for twitter's API? You might look into the smappR package: https://github.com/SMAPPNYU/smappR

    The function smappR::getFollowers() can work with multiple credentials (by default, in the '~/Dropbox/credentials' directory) to speed up the acquisition of follower IDs.

    The function smappR::getFollowers() has an argument sleep that allows you to tailor the frequency of API requests.