If you have ever searched for a "Google Trends API", you probably found three things: an alpha API from Google with a waitlist, the unofficial pytrends library that keeps breaking with HTTP 429 errors, and a lot of scraping tutorials that stop working after a week.
This guide shows a practical alternative: calling a hosted Google Trends scraper as an API. You send keywords, you get back clean JSON with interest over time, interest by region, related queries and related topics. I'll show JavaScript, Python and plain curl, and I'll be honest about the limits.
Why getting Google Trends data is harder than it looks
Google Trends has no generally available, self-serve public API. The website itself loads data from internal endpoints that need a fresh token per widget, and Google rate-limits those endpoints aggressively. That's why:
-
pytrendsscripts often fail with429 Too Many Requestsafter a few calls, especially from cloud servers. - Running your own scraper means managing cookies, proxies, retries and backoff.
- Many hosted scrapers fail a noticeable share of runs. On the Apify Store the official Trends actor's public stats have shown a failure rate above 20% at times.
What you actually want is: keywords in, JSON out, it just works, and you don't pay for failures.
The tool: Google Trends Scraper on Apify
Google Trends Scraper is an Apify Actor (a hosted, API-callable scraper). It supports:
-
Interest over time for up to 5 compared keywords (e.g.
"coffee, tea") - Interest by region: country, region/state, metro or city
- Related queries and related topics, both top and rising (including "Breakout")
- Search types: Web, News, YouTube, Images and Google Shopping
- Any country (
geo), category and time range, including custom date ranges - Automatic retries, session rotation and residential proxy fallback (proxy cost included)
Pricing is pay-per-result: about $0.002 per search that returns data (cheaper on higher Apify plans) plus a tiny start fee. Empty or failed searches are not charged. Apify's free plan includes monthly credits, which covers a lot of test searches.
Step 1: Get an Apify API token
- Create a free account at apify.com.
- Go to Settings → API & Integrations and copy your API token.
- Store it as an environment variable:
export APIFY_TOKEN=...
Step 2: Call the Google Trends API with JavaScript
npm install apify-client
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('batuweb/google-trends-scraper').call({
searchTerms: ['coffee, tea', 'matcha'], // each line = one search, commas = comparison
geo: 'DE', // '' = worldwide
timeframe: 'today 12-m',
includeInterestOverTime: true,
includeInterestByRegion: true,
includeRelatedQueries: true,
includeRelatedTopics: false,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
for (const item of items.filter((i) => i.type === 'result')) {
console.log(item.input, item.averageInterest);
}
Step 3: Or with Python
pip install apify-client
import os
from apify_client import ApifyClient
client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("batuweb/google-trends-scraper").call(run_input={
"searchTerms": ["web scraping", "coffee, tea"],
"geo": "US",
"timeframe": "today 5-y",
"gprop": "youtube", # web | news | youtube | images | froogle (Shopping)
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
if item.get("type") != "result":
continue
print(item["input"], item["averageInterest"])
for q in item.get("relatedQueries", {}).get("coffee", {}).get("rising", [])[:5]:
print(" rising:", q["query"], q.get("formattedValue"))
Loading the timeline into pandas is one line:
import pandas as pd
points = item["interestOverTime"]["points"]
df = pd.DataFrame([{"date": p["date"], **p["values"]} for p in points])
Step 4: Plain HTTP (any language, no SDK)
The synchronous endpoint runs the scraper and returns the dataset items in one request:
curl -X POST \
"https://api.apify.com/v2/acts/batuweb~google-trends-scraper/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"searchTerms":["chatgpt, gemini"],"geo":"","timeframe":"today 3-m"}'
This works from n8n, Make, Zapier, Google Apps Script or a cron job.
What the output looks like
{
"type": "result",
"input": "coffee, tea",
"terms": ["coffee", "tea"],
"geo": "DE",
"timeframe": "today 12-m",
"averageInterest": { "coffee": 24, "tea": 19 },
"interestOverTime": { "points": [{ "date": "2025-10-12T00:00:00.000Z", "values": { "coffee": 24, "tea": 19 } }] },
"interestByRegion": { "resolution": "REGION", "regions": [{ "geoCode": "DE-HE", "geoName": "Hesse", "values": { "coffee": 65, "tea": 35 } }] },
"relatedQueries": { "coffee": { "top": [{ "query": "coffee machine", "value": 100 }], "rising": [] } },
"trendsUrl": "https://trends.google.com/trends/explore?q=coffee%2Ctea&date=today+12-m&geo=DE"
}
If one section fails (for example related queries), you still get the other sections plus an explicit error field rather than losing the whole result.
Practical use cases
- SEO & content planning: find rising queries before competitors write about them.
- Seasonality: pull 5-year timelines to plan campaigns and stock levels.
- Market research: compare brands or products across countries and regions.
- Dashboards: schedule a weekly run and push results into Google Sheets or BigQuery.
- AI agents: the Actor can be called through the Apify MCP server.
Honest limitations
- Values are relative (0–100), not absolute search volumes. That is how Google Trends works; no scraper can change it.
- Comparisons are limited to 5 keywords per search, like on the Trends website.
- Very low-volume keywords may return no data. You aren't charged for those.
- Google can change its internal endpoints. The Actor is monitored weekly, but this is still scraping, not an official SLA-backed API.
- Check Google's terms and your local laws for your use case. The data is public, aggregated and anonymous.
FAQ
Is there an official Google Trends API? Google has announced an alpha Trends API with limited access. For most developers, a hosted scraper or pytrends is still the practical option.
Why not just use pytrends? It's fine for occasional local use. On servers, it hits rate limits quickly and you have to manage proxies yourself.
How much does 1,000 searches cost? Around $2 on the Free plan, less on paid plans, with no charge for empty results.
Related tools
- SEO Audit Toolkit: audit titles, meta descriptions, broken links, sitemap and robots.txt for the pages you build around rising topics.
Disclosure: I built the Google Trends Scraper Actor.
Top comments (0)