DEV Community

kevin inter
kevin inter

Posted on Fully Autonomous

Google Trends in Python after pytrends - a setup that still works in 2026

If you have a script that uses pytrends, you have probably seen it fail with TooManyRequestsError (HTTP 429), or stop working altogether. The library was archived on GitHub in April 2025 and its last release is from 2023, so those errors are not going to be fixed.

I needed Google Trends data for SEO and content work, so I looked at what still works today. Here is a short overview, then a working example you can copy.

Your options in 2026

Option Good for Watch out for
Official Google Trends API Long-term, official access Still an alpha: you have to apply and wait for approval
Free libraries (trendspy, trendspyg...) Small, occasional scripts You handle the 429 rate limits, proxies and breaking changes yourself
Hosted APIs / scrapers (SerpApi, Apify Actors...) Recurring jobs, many keywords, automations Paid per request, but someone else deals with the blocking

Google rate-limits Trends heavily, and it comes in waves: a script that works at 10 a.m. can get blocked at 11 a.m. If you only check a few keywords by hand once in a while, a free library is fine. If the data feeds a dashboard, a report or a scheduled job, it is usually cheaper to pay a fraction of a cent per keyword than to babysit proxies.

Disclosure: the example below uses a Google Trends Actor that I built and maintain on Apify. The pattern is the same with any hosted API.

A working example

Install the client and get a free Apify API token (Settings > API & Integrations; the free plan includes monthly credits):

pip install apify-client
Enter fullscreen mode Exit fullscreen mode
import os
from apify_client import ApifyClient  # pip install apify-client

client = ApifyClient(os.environ["APIFY_TOKEN"])

run = client.actor("inter974/google-trends-api").call(run_input={
    "searchTerms": ["python", "rust", "golang"],
    "geo": "US",
    "timeRange": "today 12-m",
})

for item in client.dataset(run.default_dataset_id).iterate_items():
    s = item["summary"]
    print(f'{item["searchTerm"]:8} {s["trendDirection"]:5} {s["changePercent"]:>6}%  peak on {s["peakDate"]}')

    # Google's "rising" list can contain unrelated searches: keep the ones that mention the keyword
    rising = [q for q in item.get("relatedQueriesRising", [])
              if item["searchTerm"] in q["query"].lower()]
    for q in rising[:3]:
        growth = q["growthPercent"]  # a number, or "Breakout" for +5000% and more
        print(f'         rising: {q["query"]} ({growth if growth == "Breakout" else f"+{growth}%"})')
Enter fullscreen mode Exit fullscreen mode

Output from a real run (US, past 12 months, October 2026):

golang   down   -39.5%  peak on 2026-01-25
         rising: learn golang (+800%)
         rising: golang documentation (+450%)
         rising: golang docs (+350%)
rust     flat     6.9%  peak on 2026-04-12
         rising: how to remove rust from cast iron (+900%)
         rising: breaking rust (+850%)
         rising: red rust pioneers survival crafting (+850%)
python   down   -20.4%  peak on 2026-06-14
         rising: python programming tutorial (+4300%)
         rising: python web framework (+3250%)
         rising: tom rahill everglades python hunt (+600%)
Enter fullscreen mode Exit fullscreen mode

Three things worth noticing:

  1. You get a ready-made summary (trendDirection, changePercent, peakDate, average...), so you don't have to compute it from the 0-100 time series. The full series is still there in interestOverTime if you want to plot it.
  2. Rising queries change between runs. Google computes them from a sample, so two runs a few minutes apart can return a different list. For reporting, store each run and look at what comes back repeatedly.
  3. Keywords are ambiguous. "rust" is mostly about the metal, and "python" includes snakes. That is Google's data, not a bug: when you compare topics, check the rising queries before drawing conclusions. Google Trends topics or more specific terms ("rust programming") help.

Compare keywords on the same scale

Put up to 5 terms on one line, separated by commas, to get the same comparison as the Compare button on the website:

run_input = {"searchTerms": ["chatgpt, claude, gemini"], "geo": "US", "timeRange": "today 3-m"}
Enter fullscreen mode Exit fullscreen mode

What is trending right now

Google's newer Trending now page has up to several hundred searches per country with an approximate search volume. pytrends never supported it. You can get it like this:

run = client.actor("inter974/google-trends-api").call(run_input={
    "trendingGeos": ["US"],
    "trendingHours": "24",      # 4, 24, 48 or 168 hours
    "maxTrendingItems": 5,
})
for t in client.dataset(run.default_dataset_id).iterate_items():
    print(t["rank"], t["query"], t["approxTraffic"], t["categories"])
Enter fullscreen mode Exit fullscreen mode
1 tyler huntley 500K+ ['Sports']
2 bears 500K+ ['Sports']
3 seahawks 500K+ ['Sports']
4 broncos 200K+ ['Sports']
5 dan quinn 200K+ ['Sports']
Enter fullscreen mode Exit fullscreen mode

Each item also has the % increase, related searches, the start time and up to 3 news articles explaining why it is trending.

Bonus: get alerted when your brand is trending

Add a watch list and only the trending searches that mention your words are returned (and charged):

run_input = {
    "trendingGeos": ["US", "GB"],
    "trendingHours": "4",
    "trendingWatchList": ["Netflix", "Apple", "Bitcoin"],
}
Enter fullscreen mode Exit fullscreen mode

Run it every couple of hours with a scheduler (cron, GitHub Actions, n8n, Make...) and send yourself a message when the result is not empty.

Without code

The same calls work with a single HTTP request, so you can use them from n8n, Make, Zapier or Google Sheets:

curl -X POST "https://api.apify.com/v2/acts/inter974~google-trends-api/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" -H "Content-Type: application/json" \
  -d '{"searchTerms": ["python"], "geo": "US"}'
Enter fullscreen mode Exit fullscreen mode

Cost

On the free plan it is $2 per 1,000 results (cheaper on paid plans): one keyword with its trend, regions and related queries is one result, so $0.002. Keywords that fail or have no data are not charged. Tracking 100 keywords every day costs about $6 a month.

Wrapping up

  • For a quick one-off look, the Google Trends website or a free library is enough.
  • For anything scheduled or at scale, use a service that handles the rate limits for you, and keep your code independent of it (a small function that returns the summary) so you can switch later.
  • Whatever you use, treat Trends values as relative (0-100), not search volumes.

The Actor used here is Google Trends Scraper API on Apify. I'd love feedback on what data you would like to get from Google Trends.

Top comments (0)