DEV Community

Cleanrows
Cleanrows

Posted on

Google Trends API without pytrends: bulk keywords and comparing 8+ terms in Python

If you have used Google Trends from Python, you have probably used pytrends. Its GitHub repository was archived on 17 April 2025, and the known problems are frozen in place: 429 Too Many Requests after a handful of calls, and a 5-keyword limit on comparisons. Google announced an official Trends API in July 2025, but it's an alpha for a limited number of approved testers.

So what do you use in 2026 if you need Trends data for a few hundred keywords, a weekly dashboard, or a keyword-research pipeline?

In this post I'll show the approach I use now: a hosted Actor on Apify, Google Trends API – Bulk Keywords, Compare & Trending Now, called from Python with apify-client. I built it, so I'll also explain how it works under the hood and where its limits are. Every output below is from real runs.

What we want

  1. Interest over time for many keywords and countries in one call, as rows we can put into pandas.
  2. Rising related queries (including "Breakout" ones) for content and product ideas.
  3. More than 5 keywords on one scale. Google only compares 5 at a time, and every comparison is rescaled to its own 0–100, so you can't just glue two comparisons together.
  4. Trending Now searches per country.

Setup

pip install apify-client pandas
export APIFY_TOKEN=...   # from console.apify.com → Settings → API & Integrations
Enter fullscreen mode Exit fullscreen mode

A free Apify account includes monthly platform credit. The Actor charges per row with data: $0.25 per 1,000 keyword rows and $0.10 per 1,000 Trending Now rows. Keywords without data and failed rows are free.

1. Bulk interest over time (the pytrends interest_over_time replacement)

import os
from apify_client import ApifyClient
import pandas as pd

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

run = client.actor("henryklimes/google-trends").call(
    run_input={
        "mode": "keyword",
        "keywords": ["heat pump", "padel", "sourdough"],
        "geos": ["US", "GB"],
        "timeRange": "today 5-y",
        "includeRegions": False,
        "includeRelatedQueries": False,
    },
    max_total_charge_usd=0.05,  # hard cap for this run
)

rows = list(client.dataset(run.default_dataset_id).iterate_items())
df = pd.DataFrame(rows)
print(df[["keyword", "geo", "average_interest", "peak_date", "change_percent", "trend_direction"]])
Enter fullscreen mode Exit fullscreen mode

Output (6 rows, about 15 seconds):

     keyword geo  average_interest   peak_date  change_percent trend_direction
0  heat pump  US             29.24  2026-05-17          122.06          rising
1      padel  US             27.62  2026-06-14          513.37          rising
2  heat pump  GB             49.69  2026-06-21           73.49          rising
3  sourdough  US             40.20  2026-01-18          329.60          rising
4      padel  GB             22.56  2026-08-02         1634.15          rising
5  sourdough  GB             46.86  2026-02-15          181.67          rising
Enter fullscreen mode Exit fullscreen mode

Each keyword × country is one row. The full weekly timeline (262 points for 5 years) is in the timeline column, and the summary columns are already computed:

  • average_interest: the mean of complete points
  • peak_value and peak_date
  • latest_value, plus latest_is_partial for the current, unfinished week
  • change_percent: the last quarter of the period vs the first quarter
  • trend_direction: rising, falling or stable (±10%)

Padel's +1,634% in the UK over five years is the kind of thing you can now sort a 500-keyword list by.

To chart it, flatten the timeline into long format:

timeline = df.explode("timeline")
timeline = pd.concat(
    [timeline[["keyword", "geo"]].reset_index(drop=True),
     pd.json_normalize(timeline["timeline"].tolist())],
    axis=1,
)
print(timeline.head())
Enter fullscreen mode Exit fullscreen mode
     keyword geo        date  value  is_partial
0  heat pump  US  2021-11-14     20       False
1  heat pump  US  2021-11-21     20       False
2  heat pump  US  2021-11-28     20       False
3  heat pump  US  2021-12-05     15       False
4  heat pump  US  2021-12-12     16       False
Enter fullscreen mode Exit fullscreen mode

Remember that each row is scaled 0–100 on its own. "padel US 27.6" and "heat pump US 29.2" are not comparable volumes. For that you need compare mode (section 3).

2. Rising queries for keyword research

Leave includeRelatedQueries on (it's the default), and each row also gets related_queries_top and related_queries_rising, with is_breakout flagged. Here is a 12-month US run on 20 seed keywords:

for r in rows:
    rising = [f'{q["query"]} ({q["formatted_value"]})' for q in r["related_queries_rising"][:3]]
    print(r["keyword"], r["trend_direction"], rising)
Enter fullscreen mode Exit fullscreen mode
oat milk stable ['chobani oat milk discontinued (+1,400%)', 'oat milk latte near me (+500%)', 'califia farms oat milk barista blend (+300%)']
kombucha falling ['health ade kombucha lawsuit (Breakout)', 'how to brew kombucha (+3,750%)', 'probiotic kombucha gummies (+700%)']
creatine stable ['creatine benefits sedentary adults study (Breakout)', 'omni creatine gummies reviews (+1,650%)', 'omni creatine gummies (+1,000%)']
magnesium stable ['spnutrition magnesium bisglycinate gummies reviews (+2,250%)', 'total relief magnesium cream (+1,400%)', 'dr teals magnesium spray (+1,250%)']
vitamin d falling ['university of surrey vitamin d study (Breakout)', 'vitamin d food interactions (+700%)', 'symptoms of vitamin d deficiency (+250%)']
Enter fullscreen mode Exit fullscreen mode

That's 20 keywords for $0.005.

A caveat you should know about: Google's own rising lists currently contain some obvious noise. Unrelated "Breakout" queries like "laptop stand" or "hotel booking" show up under unrelated keywords, and Wyoming tops the US region list for almost everything. That comes straight from Google, and I get the same from every network I tested. My guess is that automated traffic is leaking into Trends. Filter rising queries by whether they contain your seed term if you need clean lists.

3. Comparing more than 5 keywords on one scale

This is the part pytrends never solved. Google compares at most 5 terms, and each comparison is normalised so its own maximum is 100. The usual trick is an anchor keyword: put one shared term in every batch and rescale by it. A naive single anchor breaks down when the keywords differ a lot in size. Next to "nike", small brands round to 0 or 1, and you lose all precision.

What the Actor does instead:

  1. Pass 1: size every keyword roughly against the first one.
  2. Pass 2: sort by size and compare in batches of 5. Each batch shares one keyword with the previous one, the smallest one that still peaked at 5 or more, so every scale factor comes from two non-tiny numbers.
  3. Keywords that round to 0 next to bigger ones are re-measured in the next, smaller batch.
  4. Anything still below Google's resolution is flagged precision: "low".
run = client.actor("henryklimes/google-trends").call(
    run_input={
        "mode": "compare",
        "keywords": ["nike", "adidas", "puma", "new balance", "asics", "under armour"],
        "geos": [],               # worldwide
        "timeRange": "today 12-m",
    },
    max_total_charge_usd=0.05,
)
for r in sorted(client.dataset(run.default_dataset_id).iterate_items(), key=lambda r: r["rank"]):
    print(r["rank"], r["keyword"], r["average_interest"], r["peak_value"], r["trend_direction"], r["precision"])
Enter fullscreen mode Exit fullscreen mode
1 nike 69.63 100 stable high
2 adidas 49.15 79 stable high
3 new balance 20.88 40 stable high
4 puma 16.83 33 stable high
5 asics 10.91 15.41 stable high
6 under armour 7.67 29.08 rising high
Enter fullscreen mode Exit fullscreen mode

And here are 8 AI assistants in the US over the last 3 months:

1 chatgpt 67.39
2 gemini 28.36
3 copilot 4.59
4 claude ai 3.57
5 deepseek 1.48  (precision low)
6 perplexity 1.11
7 meta ai 0.82
8 mistral ai 0.04 (precision low)
Enter fullscreen mode Exit fullscreen mode

All values share one scale, so "gemini is ~0.42× chatgpt" is a meaningful statement, and so is "mistral ai is tiny". An 8-keyword comparison takes 4 batches (8 Google requests) and about 9 seconds.

4. Trending Now by country

run = client.actor("henryklimes/google-trends").call(
    run_input={"mode": "trendingNow", "geos": ["US", "GB", "DE", "CZ"]},
    max_total_charge_usd=0.05,
)
for r in client.dataset(run.default_dataset_id).iterate_items():
    if r["rank"] <= 2:
        print(r["geo"], r["rank"], r["title"], r["approx_traffic"], r["started_at"])
Enter fullscreen mode Exit fullscreen mode
US 1 steelers schedule 5000+ 2026-11-16T00:40:00.000Z
US 2 cowboys coach 200+ 2026-11-16T00:40:00.000Z
GB 1 h&m 500+ 2026-11-16T00:40:00.000Z
DE 2 quentin tarantino 200+ 2026-11-16T00:30:00.000Z
CZ 1 kim čong-un 200+ 2026-11-15T23:40:00.000Z
Enter fullscreen mode Exit fullscreen mode

Each row also has a picture and the news articles behind the trend. Google's feed gives about 10 per country, so schedule the run hourly on Apify if you want a history.

How it avoids the 429s

There's no magic, just being polite and persistent:

  • One cookie session per proxy IP (the NID cookie from the Trends homepage; without it the API answers 429 straight away).
  • About 1 request per second per session, 2 sessions by default.
  • It honours Retry-After, uses exponential backoff with jitter, and opens a fresh session (new cookie, new IP) after 2 failures in a row.
  • A keyword that is still blocked goes to the back of the queue and is retried after a 60–120 s cooldown. Only then does it come back as a free error row.

In my test runs, 100 keyword × country lookups finished in about 4 minutes with 0 errors.

Limits, honestly

  • Trends values are relative (0–100), not search volumes.
  • Google samples its data, so repeated runs can differ by a few points, especially for small keywords.
  • Related topics are usually withheld from automated requests. Related queries come back reliably.
  • Trending Now is limited to what Google's feed shows (about 10 per country).

Try it

If you hit a keyword or geo that fails, open an issue on the Actor page. I read them.

Disclosure: I built this Actor; the post was written with AI assistance from real runs on 16 November 2026.

Top comments (0)