New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lookup_users for more than 18,000 screen names #118
Comments
|
@rayms Thanks for pointing out the documentation number. The max number of users should be 90,000 per every 15 minutes. I've updated the documentation to be more accurate (and to make note that it's possible to iterate through more than the max...it just requires navigating rate limit resets). Eventually, this function will hopefully include a |
|
hi @mkearney , sorry to bump this - I wondered if you could advise on the code for iterating through the max number of 90,000 users? I am not sure this is doing the trick, as it seems to retrieve the first 90,000 very, very slowly. I adapted it from a previous answer you gave on the |
|
I found this issue while Googling for a lazy way around the 90,000 limit. My solution below, which might not be the most elegant but it works for me. lookup_many_users <- function(users, twitter_token, retry_limit = 5){
require(rtweet)
breaks <- seq(1, length(users), 89999)
if(breaks[length(breaks)] != length(users)){
breaks <- c(breaks, length(users))
}
user_details <- NULL
for(i in 1:(length(breaks) -1)){
attempt <- 0
while(is.null(user_details) && attempt <= retry_limit){
attempt <- attempt + 1
try({
user_details <- lookup_users(users[breaks[i]:breaks[i+1]], token = twitter_token)
Sys.sleep(15 * 60) #wait 15 minutes for rate limit to reset before proceeding
})
}
if(is.null(user_details)){
stop("failed to get users")
}
if(i == 1){
all_user_details <- user_details
} else {
all_user_details <- rbind(all_user_details, user_details)
}
user_details <- NULL
}
return(all_user_details)
} |
friend, what do I send on Twitter_token? Can you give an example? it does not work |
Is there a way to use the lookup_users function for more the max 18,000 screen names? The documentation states that the max response is 18,000 per token. Does this mean there is no way to request the data for more than 18,000 users?
The text was updated successfully, but these errors were encountered: