Error search_tweets retryonratelimit
Hi all,
I am trying to get a large amount of data on a search query, but it seems the retryonratelimit is not working. That is the code I have:
library(rtweet)
dados_bolsonaro<-search_tweets("bolsonaro", n=100000, include_rts = TRUE, retryonratelimit = TRUE)
The error:
Downloading [=========================================] 100%
retry on rate limit...
waiting about 9 minutes...
Warning: Rate limit exceeded - 88
Warning message:
Rate limit exceeded
rtweet version
packageVersion("rtweet")
[1] ‘0.7.0.9000’
Any idea what is going on? Sorry I am doing some stupid mistake, but from what I read in the documentation that was supposed to be working fine.
Note that I only see a warning (which I agree it shouldn't appear) but it is not an error and that you reached to download 100%. What is the output of head(dados_bolsonaro)?
I am running the dim function because it is easier to see what is happening. This is what I get:
dim(dados_bolsonaro)
[1] 17999 90
It is like I am getting one rate limit and stopping the query to the API.
Thanks!!
Yes the number checks with not being able to use retry on rate limit. But I cannot reproduce this outcome, to me it shows a message:
Rate limit exceeded for Twitter endpoint '/1.1/search/tweets'. Waiting for refresh in 12 mins
Could you show the output of devtools::session_info("rtweet") ?
Yes. Here it goes:
> devtools::session_info("rtweet")
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 4.0.3 (2020-10-10)
os Ubuntu 20.04.2 LTS
system x86_64, linux-gnu
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/Belem
date 2021-05-02
─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────
! package * version date lib source
askpass 1.1 2019-01-13 [1] CRAN (R 4.0.2)
bit 4.0.4 2020-08-04 [1] CRAN (R 4.0.2)
bit64 4.0.5 2020-08-30 [1] CRAN (R 4.0.2)
cli 2.4.0 2021-04-05 [1] CRAN (R 4.0.3)
crayon 1.4.1 2021-02-08 [1] CRAN (R 4.0.3)
curl 4.3 2019-12-02 [1] CRAN (R 4.0.2)
ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.2)
fansi 0.4.2 2021-01-15 [1] CRAN (R 4.0.3)
glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2)
hms 1.0.0 2021-01-13 [1] CRAN (R 4.0.3)
httr 1.4.2 2020-07-20 [1] CRAN (R 4.0.2)
jsonlite 1.7.2 2020-12-09 [1] CRAN (R 4.0.3)
lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.0.3)
magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.2)
mime 0.10 2021-02-13 [1] CRAN (R 4.0.3)
openssl 1.4.3 2020-09-18 [1] CRAN (R 4.0.2)
pillar 1.6.0 2021-04-13 [1] CRAN (R 4.0.3)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.2)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.2)
progress 1.2.2 2019-05-16 [1] CRAN (R 4.0.2)
R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.2)
rappdirs 0.3.1 2016-03-28 [1] CRAN (R 4.0.2)
rlang 0.4.10 2020-12-30 [1] CRAN (R 4.0.3)
V rtweet * 0.7.0 2021-05-02 [1] Github (ropensci/rtweet@bd470c4)
sys 3.4 2020-07-23 [1] CRAN (R 4.0.2)
tibble * 3.1.0 2021-02-25 [1] CRAN (R 4.0.3)
utf8 1.2.1 2021-03-12 [1] CRAN (R 4.0.3)
vctrs 0.3.7 2021-03-29 [1] CRAN (R 4.0.3)
withr 2.4.1 2021-01-26 [1] CRAN (R 4.0.3)
[1] /home/venturat/R/x86_64-pc-linux-gnu-library/4.0
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library
V ── Loaded and on-disk version mismatch
Weird, we both use the latest version and we don't get the same message.
You might be interested on the search_fullarchive function for this kind of massive search, or even the stream_tweets if you want the current tweets.
If you still want to use search_tweets, could you restart your R session and try again after 20 minutes of last try of this call?
Perfect! I will restart my R session, and try again later. If not, I will move to the stream_tweets.
Thanks!
Same problem.
dados_bolsonaro <- search_tweets("bolsonaro", n=100000, include_rts = TRUE, retryonratelimit = TRUE)
Downloading [=========================================] 100%
retry on rate limit...
waiting about 9 minutes...
Rate limit exceeded - 88Rate limit exceeded
dim(dados_bolsonaro)
[1] 17993 90
Any ideas?
I cannot reproduce your problem and I already suggested some workarounds. I'm afraid that I don't have any new ideas on this. Currently working on other areas so it might take a while to come back to this and explore it further, sorry.
Thanks, anyway. I understand your other solutions, and yes I can always try the stream API. But I wanted to show my students an example of using the search function to get a considerable large amount of data.
Thanks for all your help!
18000 tweets is already a considerable large amount of data. But if you need more data I'm afraid you'll need to go to premium access or API v2 Academic access.
If you are teaching I would advise against using the rtweet development version as things might change and break between now and the CRAN release.
For what it's worth, I'm having the same problem. I'm unable to use retryonratelimit.
Hi @kurtawirth, thanks for reporting back. Is your problem with search_tweets too or also on other functions? Do you have your own token?
I overlooked the "search_tweets" part of this issue - my apologies! I am having this error when using get_friends and using n = Inf and retryonratelimit = TRUE.
I do have my own token, correct!
I think that in your case there are two problems one with using n = Inf which although what the documentation says it is still not properly working (see this other bug report) and the second one with retryonratelimit, it is the same error message reported Rate limit exceeded - 88?
Understood on the n = Inf! And correct, same error: Warning: Rate limit exceeded - 88.
Hello, I have the same problem with search_tweets. The weird thing is that until now I always use the code in the same way and it always worked.
Hi Lucas, does this mean that you are using the CRAN version? Because I'm starting to think that this kind of error is a problem on Twitter side and not with rtweet code.
Yes, a week ago I had run a code very similar to TiagoVentura's in the first question. Now, every time it reaches the limit of 18k tweets it stops downloading, as if the retryonratelimit function doesn't work.
I'm not sure how this answers my question @LucasDavid12. Yes means you are using CRAN version 0.7.0? could you share the output of devtools::session_info("rtweet")
Sorry, I'm fairly new to this and there are some things I'm not used to.
-
Session info ------------------------------------------------------------------------- setting value
version R version 4.0.5 (2021-03-31) os Windows 10 x64
system x86_64, mingw32
ui RStudio
language (EN)
collate Spanish_Argentina.1252
ctype Spanish_Argentina.1252
tz America/Buenos_Aires
date 2021-09-21 -
Packages ----------------------------------------------------------------------------- package * version date lib source
askpass 1.1 2019-01-13 [1] CRAN (R 4.0.5) cli 2.5.0 2021-04-26 [1] CRAN (R 4.0.5) crayon 1.4.1 2021-02-08 [1] CRAN (R 4.0.5) curl 4.3.1 2021-04-30 [1] CRAN (R 4.0.5) ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.0.5) fansi 0.4.2 2021-01-15 [1] CRAN (R 4.0.5) glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.5) hms 1.0.0 2021-01-13 [1] CRAN (R 4.0.5) httpuv 1.6.1 2021-05-07 [1] CRAN (R 4.0.5) httr 1.4.2 2020-07-20 [1] CRAN (R 4.0.5) jsonlite 1.7.2 2020-12-09 [1] CRAN (R 4.0.5) later 1.2.0 2021-04-23 [1] CRAN (R 4.0.5) lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.0.5) magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.5) mime 0.10 2021-02-13 [1] CRAN (R 4.0.4) openssl 1.4.4 2021-04-30 [1] CRAN (R 4.0.5) pillar 1.6.0 2021-04-13 [1] CRAN (R 4.0.5) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.5) prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.5) progress 1.2.2 2019-05-16 [1] CRAN (R 4.0.5) promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.0.5) R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.5) Rcpp 1.0.6 2021-01-15 [1] CRAN (R 4.0.5) rlang 0.4.11 2021-04-30 [1] CRAN (R 4.0.5) rtweet * 0.7.0 2020-01-08 [1] CRAN (R 4.0.5) sys 3.4 2020-07-23 [1] CRAN (R 4.0.5) tibble * 3.1.1 2021-04-18 [1] CRAN (R 4.0.5) utf8 1.2.1 2021-03-12 [1] CRAN (R 4.0.5) vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.0.5)
[1] E:/Program Files/R-4.0.5/library