Skip to content
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

Does related queries work? I keep getting 429 #625

Open
josh-ashkinaze opened this issue Jul 15, 2024 · 20 comments
Open

Does related queries work? I keep getting 429 #625

josh-ashkinaze opened this issue Jul 15, 2024 · 20 comments

Comments

@josh-ashkinaze
Copy link

josh-ashkinaze commented Jul 15, 2024

Here is a MRE, using what is in README

from pytrends.request import TrendReq
kw_list = ["Blockchain"]
pytrends = TrendReq(hl='en-US', tz=360)
pytrends.build_payload(kw_list, cat=0, timeframe='today 5-y', geo='', gprop='')
pytrends.related_queries()

This throws a 429 errors. I tried wrapping this with tenacity and I keep getting 429s no matter how long I wait.

@liusaint
Copy link

the same

@lapiceroazul4
Copy link

Same for me, It appers that only a few methods keep working.

The following are working

  • realtime_trending_searches()
  • trending_searches(pn='united_states')
  • suggestions(keyword='coronavirus')
  • categories()

Suggestions & Categories are not performing that well

@hl105
Copy link

hl105 commented Jul 19, 2024

build_payload() doesn't seem to be working for me

@lapiceroazul4
Copy link

How you're doing it?

@saadadeo
Copy link

it's same for me I've been attempting to make API calls using PyTrends, but I keep receiving an HTTP error 429, which indicates "Too Many Requests." This error typically occurs when the rate limit for API requests is exceeded. However, the strange part is that I encounter this error even when I make only a single API call.

@claudioferrazb
Copy link

the same here =/

@Toffee1878
Copy link

Same for me, It appers that only a few methods keep working.

The following are working

  • realtime_trending_searches()
  • trending_searches(pn='united_states')
  • suggestions(keyword='coronavirus')
  • categories()

Suggestions & Categories are not performing that well

Can I ask what payload you are using please?

@lapiceroazul4
Copy link

lapiceroazul4 commented Jul 22, 2024

Same for me, It appers that only a few methods keep working.
The following are working

  • realtime_trending_searches()
  • trending_searches(pn='united_states')
  • suggestions(keyword='coronavirus')
  • categories()

Suggestions & Categories are not performing that well

Can I ask what payload you are using please?

Sure!, here it is

pytrend = TrendReq(hl='en-US', tz=360, retries=3)

pytrend.build_payload(kw_list=['whatever word you want'])

-To get realtime trendings

df = pytrend.realtime_trending_searches(pn='US')
df.head(10)

-To get top searches in US

df = pytrend.trending_searches(pn='united_states')
df.head(10)

-To get suggestions based on a word

df = pytrend.suggestions(keyword='obamacare')
print(df)

-To get related categories

df = pytrend.categories()
print(df)
  • To get today's searches in US
df = pytrend.today_searches(pn='US')
df.head(2)

Please note that these methods are working but some others are not. This is because Pytrends is not an official API, it is an open source project that actually scraps the data from Google Trends, this implies that often we may find errors in Pytrends every time Google change something in the Google Trend's Page

@Toffee1878
Copy link

Same for me, It appers that only a few methods keep working.
The following are working

  • realtime_trending_searches()
  • trending_searches(pn='united_states')
  • suggestions(keyword='coronavirus')
  • categories()

Suggestions & Categories are not performing that well

Can I ask what payload you are using please?

Sure!, here it is

pytrend = TrendReq(hl='en-US', tz=360, retries=3)

pytrend.build_payload(kw_list=['whatever word you want'])

-To get realtime trendings

df = pytrend.realtime_trending_searches(pn='US')
df.head(10)

-To get top searches in US

df = pytrend.trending_searches(pn='united_states')
df.head(10)

-To get suggestions based on a word

df = pytrend.suggestions(keyword='obamacare')
print(df)

-To get related categories

df = pytrend.categories()
print(df)
  • To get today's searches in US
df = pytrend.today_searches(pn='US')
df.head(2)

Please note that these methods are working but some others are not. This is because Pytrends is not an official API, it is an open source project that actually scraps the data from Google Trends, this implies that often we may find errors in Pytrends every time Google change something in the Google Trend's Page

@lapiceroazul4 - Thank you very much.

@KatMerrill
Copy link

Are the other methods being fixed currently, or does anyone know of good ways to work around them? I'm trying to use interest_over_time() and it seems to have completely stopped working, probably when Google Trends updated recently. I've been consistently getting 429 errors on my first request, and haven't had luck with changing backoff_factor/retries, using proxies, or even running it on a different computer and network.

@javathejhut
Copy link

Starting to see data coming in now, but slowly. No immediate 429.

@guaribr
Copy link

guaribr commented Aug 5, 2024

I am also having the "TooManyRequestsError: The request failed: Google returned a response with code 429" error

@jabeztadesse
Copy link

How the hell are these guys able to do it? 🤔 https://serpapi.com/playground?engine=google_trends&q=Coffee

@HumanBot000
Copy link

interest_over_time() only returns 429 for me also

@lapiceroazul4
Copy link

How the hell are these guys able to do it? 🤔 https://serpapi.com/playground?engine=google_trends&q=Coffee

Idk how they do that, but, it looks awesome, any idea of how can we get that data?

@HumanBot000
Copy link

How the hell are these guys able to do it? 🤔 https://serpapi.com/playground?engine=google_trends&q=Coffee

Idk how they do that, but, it looks awesome, any idea of how can we get that data?

hmm..

@jabeztadesse
Copy link

How the hell are these guys able to do it? 🤔 https://serpapi.com/playground?engine=google_trends&q=Coffee

Idk how they do that, but, it looks awesome, any idea of how can we get that data?

hmm..

Got any idea?

@HumanBot000
Copy link

I just know, that if I try to replicate the http calls my browser does in postman, I keep getting an error that this isn't a browser. So my guess would be, that they are just web scraping it. When you use their API (with only 100 free calls/months) my guess would be, that they have headless browsers running on a server.

@gl2007
Copy link

gl2007 commented Aug 17, 2024 via email

@franz101
Copy link

franz101 commented Sep 5, 2024

My personal workaround for similar data is to use the wikipedia api:
see python wikipedia api for page views

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests