PMassicotte/gtrendsR

Status code was not 200. Returned status code:429

ReemOmer opened this issue · 3 comments

I am trying to collect trends data for more than 5 keywords following the suggested solution on this tutorial. However, I can't get all the data due to this error:
__Error_ in FUN(X[[i]], ...) : Status code was not 200. Returned status code:429_

Here is the part that generates the error:

install.packages("readr")
install.packages("colorspace")
install.packages("vctrs")
install.packages("gtrendsR")
library(gtrendsR)
keywords <- c("X", "Y", "Z", "A", "B")
country <- c("US")
time <- ("2019-10-31 2022-10-31")
trends <- gtrends(keywords, geo = country, time = time)

same error,
with code that used to work at least a couple of weeks ago.

You should search opened issues: #431

As @ReemOmer already commented for the same issue with pytrends (GeneralMills/pytrends#538), this is related to how Google block requests after a while. Please check what is 429 error is about: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429.

Google Trends do not offer a proper API, gtrendsR and pytrends are just "hacking" it to retrieve data. We do not have control on how many requests one can perform.

It's me actually 😅 and wanted to know if there are any workarounds in gtrendsR. Thanks