Disclosure: I made the Actor used in this article, so I'm biased. Apify links here are referral links. The same steps work with any tool that returns Trends data as JSON; I note a free alternative below.
Google does not offer a public API for the charts on trends.google.com. For years the usual Python answer was pytrends. That repository is archived (the owner archived it on 17 April 2025; the last commit is from 22 April 2023). People still clone it, and many of those scripts now die on HTTP 429 or empty results once Google tightens rate limits.
Here is a small Python script that pulls interest over time, related queries and interest by region for a list of keywords, writes a CSV, and does not need a Google account or API key.
What you'll need
- Python 3.9 or newer
- A free Apify account (new accounts include free monthly platform credit, so the example below costs well under a cent; please check the current credit on Apify's pricing page)
- Your Apify API token, from Settings → API & Integrations
pip install -U apify-client pandas
export APIFY_TOKEN="your-token-here"
Step 1: Run the Actor on a short keyword list
Google Trends Scraper takes a list of keywords (and optional country codes) and returns one row per keyword. Pricing is $0.003 per keyword result ($3 per 1,000). Comparisons of several keywords on one chart are charged once per keyword in the group. Searches with no data, and failed searches, are not charged.
import os
import pandas as pd
from apify_client import ApifyClient
client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("logicbase_systems/google-trends").call(run_input={
"keywords": ["air fryer", "instant pot"],
"geos": ["US"],
"timeframe": "today 12-m",
"includeRelatedQueries": True,
"includeInterestByRegion": True,
})
Two keywords in one country keep the test cheap (about $0.006 plus a tiny start fee). Change the words, add "GB" or "IN" to geos, or switch timeframe to "today 3-m" or "today 5-y" once you're happy. Leave geos out for a worldwide search.
Step 2: Read the results
rows = list(client.dataset(run.default_dataset_id).iterate_items())
ok = [r for r in rows if r.get("status") == "ok"]
print(f"{len(ok)} keyword results, {len(rows) - len(ok)} with no data or an error")
Every row has status. A wrong country code or a term Google has no data for comes back as "error" or "no_data" with a reason, and is not charged. Each good row has a summary (average, peak, peak date, latest value), the full interest-over-time series, related queries (top and rising, when Google has them), and interest by region.
On 16 November 2026 I ran a 40-keyword worldwide batch on this Actor: all 40 rows had a 53-point interest series, a summary and regional interest; 29 of 40 had a top related-query list and 20 of 40 a rising list. The run took 56 seconds. Larger batches the same day were 150 of 150 keywords in 97 seconds and 195 of 195 in 142 seconds.
Step 3: Save a spreadsheet-friendly CSV
flat = []
for r in ok:
flat.append({
"keyword": r.get("keyword"),
"geo": r.get("geo") or "worldwide",
"averageInterest": (r.get("summary") or {}).get("average"),
"peakInterest": (r.get("summary") or {}).get("peak"),
"peakDate": (r.get("summary") or {}).get("peakDate"),
"latestInterest": (r.get("summary") or {}).get("latest"),
"topRelatedQuery": ((r.get("relatedQueries") or {}).get("top") or [{}])[0].get("query"),
"risingRelatedQuery": ((r.get("relatedQueries") or {}).get("rising") or [{}])[0].get("query"),
})
pd.DataFrame(flat).to_csv("trends_summary.csv", index=False)
# Optional: one row per week of the interest series
series_rows = []
for r in ok:
for point in r.get("interestOverTime") or []:
series_rows.append({
"keyword": r.get("keyword"),
"geo": r.get("geo") or "worldwide",
"date": point.get("date") or point.get("time"),
"interest": point.get("value") or point.get("interest"),
})
if series_rows:
pd.DataFrame(series_rows).to_csv("trends_interest_over_time.csv", index=False)
Field names inside summary, relatedQueries and interestOverTime follow the Actor's output schema. If a key is missing on a row, the .get calls above just leave a blank cell.
Compare keywords on the same 0–100 scale
A normal keyword list is one independent search per term, so the 0–100 scale is not shared. To compare terms the way the Trends website does, pass a comparison group:
run = client.actor("logicbase_systems/google-trends").call(run_input={
"comparisonGroups": ["python | javascript | rust"],
"geos": ["US"],
"timeframe": "today 12-m",
})
That returns one row with all three series on a shared scale. It is charged as three keyword results ($0.009). A comparison of those three languages took 10 seconds on a 16 November 2026 run. On a comparison row, each interest-over-time point has a values map (one number per keyword) instead of a single value, and summary is also keyed by keyword.
Trending now, by country
run = client.actor("logicbase_systems/google-trends").call(run_input={
"trendingGeos": ["US", "GB", "IN"],
"maxTrendingPerGeo": 10,
})
This uses Google's trending-now feed, not the interest chart. Pricing is $0.001 per topic. A run for the US, UK and India returned 30 topics in 5 seconds on 16 November 2026.
Things to know before you rely on it
- There is no official Google Trends API for this data. The Actor reads the public Trends website. Automated access can be rate-limited; failed rows are free.
- Related topics are not included. Google returns an empty related-topics list to automated clients. Rather than charge for empty data, the Actor leaves them out. Related queries (top and rising) work. Rising lists for very broad worldwide keywords can contain one-off breakout searches; pick a country or a narrower keyword for a cleaner rising list.
- Interest values are relative (0–100), not absolute search counts. Compare keywords in one
comparisonGroupsentry if you need them on the same scale. - Check that your use of the data respects Google's terms.
The free DIY alternative
For a handful of keywords, the Trends website itself can export a CSV (Download on the chart). That is free and official.
If you want to script it yourself, some people still use pytrends or a fork, from a home IP, with sleeps between requests. That can work for a few keywords and then start returning 429s, especially from a cloud server. Handling retries, cookies and rotating IPs is the part a hosted tool takes off your hands.
Ready-made Task pages, if you would rather press Start than write code:
- Keyword interest over time
- Compare keywords
- Related queries
- Trending now by country
- Interest by region
If something doesn't work for you, open an issue on the Actor page and I'll look at it.
Top comments (0)