DEV Community

Datafaro
Datafaro

Posted on

Google Trends data in 2026: pytrends is dead, here's what works

If you've tried to pull Google Trends data into a script recently, you've probably hit the same wall I did:

  • pytrends was archived in April 2025 and breaks regularly against Google's current endpoints.
  • Google announced an official Trends API in July 2025, but it's still an application-only alpha. Most developers can't get in.
  • Calling Google's internal endpoints yourself works for a while, then you get 429 Too Many Requests and spend your evening on cookies, tokens and proxies. This post shows a simple way to get Google Trends data from Python, from the command line and from an AI agent, with one call and no scraping code on your side.

What you can get

Four modes, all on Google's usual 0–100 relative scale:

Mode What it returns
compare Interest over time for 1–5 keywords, plus average, peak and trend direction
by_region Which countries (or regions) search most for a keyword
related Related and rising queries for a keyword
trending_now What a country is searching for right now, with approximate volume and news headlines

Every result also includes a one-sentence summary, which is handy if you're feeding the data to an LLM.

1. Quick test with curl

Get a free API token from Apify (Console → Settings → API & Integrations), then:

curl -X POST "https://api.apify.com/v2/acts/datafaro~google-trends-api/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mode": "compare", "keywords": ["chatgpt", "claude", "gemini"], "geo": "WORLD", "timeframe": "past_12_months"}'
Enter fullscreen mode Exit fullscreen mode

run-sync-get-dataset-items waits for the run and returns the results directly. A typical comparison takes around 6–8 seconds.

2. From Python

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

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("datafaro/google-trends-api").call(run_input={
    "mode": "compare",
    "keywords": ["chatgpt", "claude", "gemini"],
    "geo": "WORLD",            # or a 2-letter country code like "US", "ES"
    "timeframe": "past_12_months",
})

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["keyword"], item["trend"], item["average"])
    print("  ", item["summary"])
Enter fullscreen mode Exit fullscreen mode

When I ran this in November 2026, the summaries looked like this:

chatgpt stable 85
   Search interest in "chatgpt" worldwide over the past 12 months is stable (-2% last vs first quarter); it peaked at 100 on 2025-11-16 and averaged 85 ...
claude rising 17
   Search interest in "claude" worldwide over the past 12 months is rising, up 299% from the first to the last quarter ...
gemini rising 47
   Search interest in "gemini" worldwide over the past 12 months is rising, up 30% from the first to the last quarter ...
Enter fullscreen mode Exit fullscreen mode

Each item also has points (the full weekly series as {date, value}) if you want to chart it with pandas or matplotlib:

import pandas as pd

items = list(client.dataset(run["defaultDatasetId"]).iterate_items())
df = pd.concat(
    pd.DataFrame(i["points"]).assign(keyword=i["keyword"]) for i in items
).pivot(index="date", columns="keyword", values="value")
df.plot(title="Google Trends: ChatGPT vs Claude vs Gemini")
Enter fullscreen mode Exit fullscreen mode

3. Which countries search most for something

run = client.actor("datafaro/google-trends-api").call(run_input={
    "mode": "by_region",
    "keywords": ["bitcoin"],
    "geo": "WORLD",
})
Enter fullscreen mode Exit fullscreen mode

Result summary: Top countries for "bitcoin" worldwide over the past 12 months: Switzerland (100), Austria (93), Germany (83), Netherlands (82), Slovenia (78). Useful for picking markets for a product or a campaign.

4. What's trending right now

run = client.actor("datafaro/google-trends-api").call(run_input={
    "mode": "trending_now",
    "geo": "ES",
})
Enter fullscreen mode Exit fullscreen mode

You get the top trending searches for that country, each with approximate search volume, when it started trending and the related news headlines, so you can see why something is trending, not just that it is.

5. From an AI agent (Claude, ChatGPT, Cursor)

This is the part I care most about. Apify runs an MCP server, so an agent can call the Actor as a tool. Add this MCP server URL to your client:

https://mcp.apify.com/?tools=datafaro/google-trends-api
Enter fullscreen mode Exit fullscreen mode

Then just ask in plain language:

  • "Compare ChatGPT, Claude and Gemini on Google Trends worldwide over the last year."
  • "What's trending on Google in Spain right now, and why?"
  • "Which countries search most for 'electric bikes'?" The outputs are deliberately small and flat (a summary line plus a few fields), so they fit in an agent's context without blowing up your token count.

A few things to know about Trends data

  • Values are relative, not absolute. 100 is the peak in the selected time range and region. You can't compare numbers across separate queries; put the keywords you want to compare in the same compare call (up to 5).
  • Low-volume keywords are noisy. If most points are 0, the summary flags it as sparse data.
  • Trending Now is per country. There's no worldwide trending list in Google Trends; if you don't pass a country, it uses the US and says so.

Wrapping up

If you just need Trends data occasionally, the Google Trends website is fine. If you need it in a script, a scheduled job or an AI agent, a hosted tool saves you from maintaining the rate-limit and token handling yourself.

The Actor is here: apify.com/datafaro/google-trends-api. I'd love feedback, especially on what other Trends data you'd want an agent to have access to.

Disclosure: I built the tool used above, a Google Trends Actor on the Apify platform. I wrote it because I needed reliable Trends data for agents and kept fighting rate limits. It's pay-per-query (about $0.0035 per query) and Apify's free plan includes $5/month of credit, so you can try everything here for free.

Top comments (0)