DEV Community

Meridian Labs Software
Meridian Labs Software

Posted on

pytrends is dead. Here's a maintained drop-in replacement

pytrends stopped getting updates in April 2025

If you've used pytrends to pull Google Trends data, you've probably noticed it's gotten flakier over the last year. That's because the repo was archived by its owner in April 2025 — no more fixes, ever.

The core problem it never solved well: pytrends fires every request straight from your own IP with no cookie handling, so as soon as you run more than a handful of lookups you get hit with Google's 429 Too Many Requests.

What I built

google-trends-api-python is a drop-in replacement that keeps pytrends' exact interface (TrendReq, build_payload, interest_over_time(), all the same DataFrame shapes) but routes requests through a hosted backend instead of your machine. Proxies and retries run server-side, so there's nothing to handle yourself.

Swap two lines:

from google_trends_api import TrendReq  # was: from pytrends.request import TrendReq

pytrends = TrendReq(hl="en-US", tz=360, apify_token="<YOUR_APIFY_TOKEN>")
pytrends.build_payload(["air fryer", "standing desk"], timeframe="today 12-m", geo="US")
df = pytrends.interest_over_time()
Enter fullscreen mode Exit fullscreen mode

Everything else — interest_by_region(), related_queries(), timeframe strings, gprop — works the same as pytrends. There's a full mapping table in the README for anything that changed.

Bonus: bulk mode, and a summary() pytrends never had

For more than a handful of keywords there's a second class that batches hundreds of lookups in one call:

from google_trends_api import GoogleTrends

gt = GoogleTrends(max_cost_usd=2.00)
res = gt.lookup(
    ["halloween costume", "pool float", "ski jacket", "sunscreen"],
    geo="US",
    timeframe="today 5-y",
)

print(res.summary()[["momentum", "yearOnYearChangePct", "seasonal", "seasonalPeakMonth"]])
Enter fullscreen mode Exit fullscreen mode

summary() gives you momentum, year-on-year change, seasonality and peak month per keyword, computed server-side — nothing pytrends had.

The honest bit: it's not free

This isn't a "free API" trick. It calls a hosted Actor on Apify ($0.005 per keyword lookup), and Apify's free plan gives you $5/month, so roughly 1,000 lookups before you'd pay anything. Figured that's worth saying upfront rather than people finding out after installing.

Links

If you hit a case the pytrends mapping doesn't cover, open an issue — happy to take PRs too.

Top comments (0)