Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Google Trends API for Python - a maintained pytrends alternative

pytrends is no longer maintained and breaks constantly on Google's 429 Too Many Requests. This is a small, dependency-light client that keeps working:

  • Exponential backoff with jitter and a fresh session (new cookies) on every retry
  • Optional proxy rotation - pass a function that returns a new proxy URL per session
  • Partial results are kept - if one widget fails you still get the others
  • Interest over time, interest by region, related queries (top + rising)

Install

pip install requests
git clone https://github.com/janik4321sdfa/google-trends-api-python
cd google-trends-api-python

Usage

from gtrends import keyword_report

r = keyword_report("electric bike", geo="US", timeframe="today 12-m")
print(r["interestOverTime"][:3])
print(r["interestByRegion"][:5])
print(r["relatedQueries"]["rising"][:5])

With your own rotating proxies:

from gtrends import TrendsClient
client = TrendsClient(proxy_factory=lambda session_id: f"http://user-session-{session_id}:pass@proxy.example:8000")
report = client.keyword_report("ai agents", geo="GB")

Timeframes use the Google Trends syntax: now 7-d, today 1-m, today 3-m, today 12-m, today 5-y, 2024-01-01 2024-12-31.

Running at scale

Google Trends rate-limits single IPs hard. For hundreds or thousands of keywords per day, use the hosted version with residential IP rotation and pay only for successful keywords:

Google Trends Scraper on Apify - $3 per 1,000 keywords, failed keywords are never charged.

Related: Google Trending Now - Keyword Suggestions - Google Flights (Python)

License

MIT - unofficial, not affiliated with Google.

About

Maintained Google Trends API client for Python - pytrends alternative with retries, session and proxy rotation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages