Google Trends Structured Data Without Scraping
Google blocks Trends scrapers. Apify actors break. Getting structured trend data via search API returns trending queries as JSON without the maintenance.
Google Trends does not have an official API. Every "Google Trends API" you find is a scraper pretending to be an API. They break regularly because Google changes the Trends frontend every few months. The reliable alternative is pulling trending search data through a search API that returns structured JSON — no browser automation, no CSS selector maintenance.
Why Trends scrapers keep breaking
Google Trends renders data client-side using dynamically generated JavaScript. Scraping it requires either a headless browser (Puppeteer, Playwright) or reverse- engineering the internal XHR endpoints. Both approaches fail when Google rotates endpoint paths, changes response formats, or adds new bot detection. Apify actors for Google Trends have a median lifespan of 2-3 months before needing a rewrite.
The pytrends library, once the go-to, has been rate-limited into near-uselessness since late 2025. Google throttles unauthenticated requests aggressively, and authenticated requests require a Google account that risks getting banned.
What you actually need from Trends data
Most Trends use cases boil down to three questions: What topics are trending right now? How does search interest for keyword A compare to keyword B over time? What related queries are rising? A search API can answer the first and third directly. The second requires historical data that most search APIs do not store — but you can build your own time series by polling daily.
import requests
from datetime import datetime
def get_trending_topics(category: str) -> dict:
"""Pull currently trending search topics as JSON."""
resp = requests.post(
"https://api.scavio.dev/api/v1/search",
headers={"x-api-key": "YOUR_API_KEY"},
json={
"query": f"trending {category} topics today",
"platform": "google",
"num_results": 10
}
)
return {
"date": datetime.utcnow().isoformat(),
"category": category,
"results": resp.json().get("results", [])
}
# Daily poll for your niche
topics = get_trending_topics("AI tools")
for t in topics["results"]:
print(f"{t.get('title', 'N/A')} - {t.get('url', '')}")Building a DIY trends tracker
Instead of scraping Google Trends directly, query a search API daily for your target keywords and store the result counts and snippets. Over 30 days, you build a time series that shows relative interest changes. It is not the same granularity as Trends' interest- over-time graph, but it captures directional shifts reliably.
import json
import os
TRACKER_FILE = "trends_tracker.json"
def track_keyword(keyword: str):
"""Append daily search result snapshot for a keyword."""
resp = requests.post(
"https://api.scavio.dev/api/v1/search",
headers={"x-api-key": "YOUR_API_KEY"},
json={
"query": keyword,
"platform": "google",
"num_results": 10
}
)
data = resp.json()
history = []
if os.path.exists(TRACKER_FILE):
with open(TRACKER_FILE) as f:
history = json.load(f)
history.append({
"keyword": keyword,
"date": datetime.utcnow().isoformat(),
"result_count": len(data.get("results", [])),
"top_titles": [
r.get("title", "") for r in data.get("results", [])[:3]
]
})
with open(TRACKER_FILE, "w") as f:
json.dump(history, f, indent=2)
# Run daily via cron
track_keyword("gemma 4 local deployment")
track_keyword("claude mcp tools")Cost comparison
Apify Google Trends actors cost $29+/mo on the starter plan and require monitoring for breakage. SerpAPI offers a Google Trends endpoint at $25+/mo but throttles heavily on lower tiers. Building your own tracker with Scavio costs $0.005/query — tracking 20 keywords daily runs about $3/mo. DataForSEO offers similar at $0.0006/req if you need higher volume.
Limitations to know
This approach does not replicate Google Trends' normalized interest score (the 0-100 scale). It does not show geographic breakdowns natively. And it lags real-time trends by however often you poll. For most content marketing and product research use cases, daily polling of search results gives you enough signal. For real-time viral trend detection, you need a different approach — Reddit and TikTok trending endpoints are often faster indicators anyway.
When to still use Google Trends directly
If you need the actual normalized interest-over-time chart for a one-off research question, just use the Trends website manually. The scraping problem only matters when you need automated, recurring data pulls. For those, a search API that returns structured JSON is more reliable than any scraper you will maintain.