How to Fix pytrends 429 Too Many Requests & Broken Endpoints (2026)
You add time.sleep(10), switch to a mobile hotspot, and pytrends still throws HTTP 429 on the very first call. Here is what actually broke, every real option available in 2026, and how to migrate cleanly.

ROOT CAUSE
Archived Apr 2025
OPTIONS AUDITED
4 Real 2026 Paths
LOCAL MODE
$0 Direct IP
429 FALLBACK
--egress actor-public
TL;DR // KEY FACTS
GeneralMills/pytrendswas officially archived read-only on April 17, 2025; its staleNIDcookie handshake triggers HTTP 429 on request #1 andtrending_searches()returns HTTP 404.- In 2026, four real options exist: temporary
request.pypatches, pure-Python forks liketrendspy, paid SERP APIs / gated official Alpha, or MIT-licensedgoogle-trends-for-agent(gtfa). gtfaruns$0unlimited on your local IP orHTTPS_PROXY, replacestrending_searches()withgtfa now, and recovers from AWS/CI datacenter 429s via--egress actor-public.
01 // WHAT ACTUALLY BROKE
You didn't scrape too fast—pytrends is failing on request #1
It usually starts on a Monday morning. A Python script that has quietly pulled Google Trends data for months suddenly dies with TooManyRequestsError: Google returned a response with code 429. Your first instinct is to slow it down: you add time.sleep(10), cut the batch size to one keyword, maybe even tether to your phone's hotspot. It still throws 429 on the very first call.
When you open GeneralMills/pytrends on GitHub to check for a patch, the reason is sitting in a yellow banner at the top: the repository was officially archived read-only on April 17, 2025. Its session initializer (GetGoogleCookie()) still depends on an outdated NID cookie and consent handshake that Google now rejects upfront.
Digging through the final issues reveals three separate failures—and the third is the most dangerous: first, stale cookie handshakes trigger HTTP 429 on request #1; second, trending_searches() and realtime_trending_searches() return HTTP 404/400 because Google retired those endpoints; third, even when a request does not throw, Google's anti-bot layer (USER_TYPE_SCRAPER) can silently serve empty DataFrames, IndexError crashes, or decoy numbers in related_queries() that do not match what a human sees in a browser.
gtfa) runs free on your local IP or HTTPS_PROXY and switches to residential cloud egress with one flag when datacenter IPs are throttled.02 // HONEST LANDSCAPE COMPARISON
Every real option available in 2026—and the trade-offs of each
Before rewriting anything, it helps to look honestly at all four paths developers are actually using right now. There is no single silver bullet; the right choice depends on whether you are fixing a one-off notebook, running a light daily cron, or feeding a high-volume production pipeline.
| Option | Best for | Cost | Honest trade-offs |
|---|---|---|---|
| Patch pytrends/request.py (get → post) | Emergency hotfix due this afternoon | $0 | Wiped out on every venv/Docker rebuild; does not fix 404 trending_searches(); still relative 0–100 only. |
| Community Python fork (e.g. trendspy) | Staying 100% pure Python (pip install) for light scripts | $0 | Great lightweight Python bridge, but still hits 429 on AWS/CI IPs and returns relative 0–100 curves. |
| Official Trends API (Alpha) or SerpApi / DataForSEO | Funded teams needing an SLA and high concurrency | Gated / $50–$150+/mo | Google's Jul 2025 Alpha is still application-gated; commercial APIs are reliable but pricey for indie workflows. |
| google-trends-for-agent (MIT CLI + MCP) | Indie devs, SEO/data scripts, and AI agents needing real volume + 429 fallback | $0 local · $5/mo Apify free tier | Unofficial endpoints (not for bulk scraping/SLA); requires Node.js 20+ so Python calls it via subprocess. |
03 // STEP 1 · MAP & REPLACE INTEREST_OVER_TIME()
Stop monkey-patching site-packages: verify connectivity and swap the call
If you decide to migrate to meka-im/google-trends-for-agent (available on npm), start by mapping each legacy pytrends call in your repo to its gtfa equivalent. Notice that every core workflow—time series, rising queries, live trending feeds, comparisons, and regional scores—maps cleanly 1:1.
Instead of editing site-packages/pytrends/request.py and hoping your next Docker build doesn't overwrite it, run gtfa doctor --json to confirm Google Trends is reachable from your machine in two seconds, then call gtfa snapshot from Python via subprocess.
pytrends call maps to a deterministic gtfa command with explicit error codes instead of silent empty DataFrames.# Old StackOverflow workaround: editing venv/.../pytrends/request.py line 88
# Breaks on every container rebuild and still returns uncalibrated 0..100 curves
from pytrends.request import TrendReq
pytrends = TrendReq(hl="en-US", tz=360, retries=3, backoff_factor=0.5)
pytrends.build_payload(["seo tools"], timeframe="today 12-m", geo="US")
# TooManyRequestsError: The request failed: Google returned a response with code 429
df = pytrends.interest_over_time()import json, subprocess
# 1. Verify Google Trends reachability from your machine first:
# npx -y -p google-trends-for-agent gtfa doctor --json
# 2. Drop-in replacement inside existing Python scripts:
res = subprocess.run(
[
"npx", "-y", "-p", "google-trends-for-agent",
"gtfa", "snapshot", "seo tools",
"--geo", "US", "--time", "today 12-m", "--json",
],
capture_output=True, text=True, check=True,
)
payload = json.loads(res.stdout)
print(payload["traffic"]) # Calibrated daily searches + series + explicit statusTip: run npm install -g google-trends-for-agent once so Python can call gtfa directly without npx startup overhead.
04 // STEP 2 · RESCUE DEAD TRENDING_SEARCHES() CRONS
Replace 404-broken trending_searches() scrapers with gtfa now
If your scheduled job pulls daily headlines, finance sentiment, or content topics via pytrends.trending_searches(pn='united_states'), no cookie patch will bring it back—Google simply retired that JSON endpoint.
gtfa now queries Google's current Trending Now feed across up to 30 countries in one command, letting you filter by lookback window (--hours 4|24|48|168) and minimum search volume (--min-volume), and pipe clean CSV straight into your cron or spreadsheet.
from pytrends.request import TrendReq
pytrends = TrendReq(hl="en-US", tz=360)
# Fails with ResponseError: The request failed: Google returned a response with code 404
daily = pytrends.trending_searches(pn="united_states")
print(daily.head(20))# Pull live 24h trending searches across US, GB, and JP into a CSV file
npx -y -p google-trends-for-agent gtfa now \
--geo US,GB,JP \
--hours 24 \
--min-volume 50000 \
--limit 20 \
--format csv > trending_today.csv05 // STEP 3 · CLOUD CI FALLBACK & HOW TO CHOOSE
When AWS or GitHub Actions IPs still get 429—and how to decide
Even with a clean client, moving a script from your laptop to AWS, GCP, or GitHub Actions introduces a second problem: Google aggressively rate-limits shared datacenter IP ranges. Locally, gtfa runs $0 unlimited on your own IP or HTTPS_PROXY. When a cloud runner hits 429, you do not need to maintain a custom proxy pool—just add --egress actor-public with your APIFY_TOKEN.
That single flag routes the exact same command through our open-source Apify Actor over residential proxies, with $0 idle cost and ~3,000–7,000 queries covered by Apify's $5/month free tier.
- Need a 100% pure Python
pip installfor quick local 0–100 charts? Try a community fork liketrendspy. - Running high-concurrency enterprise pipelines with a strict SLA? Pay for SerpApi or DataForSEO (or apply to Google's official Alpha).
- Want
$0local runs, 1-flag cloud 429 recovery, real daily search volume, and MCP support for AI agents? Use google-trends-for-agent.
import time
from pytrends.request import TrendReq
pytrends = TrendReq(
proxies=["http://user:pass@proxy1:8000", "http://user:pass@proxy2:8000"],
retries=5, backoff_factor=1.0,
)
for kw in ["ai video", "voice agent", "mcp server"]:
pytrends.build_payload([kw], timeframe="now 7-d", geo="US")
# Still dies mid-batch when a proxy IP gets challenged
df = pytrends.interest_over_time()
time.sleep(2)# Local machine ($0 unlimited) or your own HTTPS_PROXY:
gtfa compare "ai video" "voice agent" "mcp server" --geo US --calibrate --format csv
# In CI / AWS / GitHub Actions when datacenter IPs hit HTTP 429:
export APIFY_TOKEN="apify_api_..."
gtfa compare "ai video" "voice agent" "mcp server" \
--geo US --calibrate --egress actor-public --format csvNext: turn Google Trends 0–100 scores into real daily search volume
Once your requests stop throwing 429, the next trap is misreading relative 0–100 peaks. Read our companion walkthrough How to Get Real Daily Search Volume from Google Trends or test the interactive demo.
FAQ
FREQUENTLY ASKED QUESTIONS
- Why does pytrends return HTTP 429 on the very first request?
- GeneralMills/pytrends was archived read-only on April 17, 2025. Its GetGoogleCookie() initializer still uses an outdated NID cookie and consent flow, so Google rejects the session upfront with HTTP 429 even from a clean residential IP.
- Can patching pytrends/request.py fix trending_searches() 404 errors?
- No. Changing requests.get to requests.post in request.py only temporarily patches cookie initialization and breaks on virtualenv or Docker rebuilds. Google retired the legacy daily-trends endpoint behind trending_searches(), so it returns HTTP 404 regardless. Use gtfa now instead.
- Does google-trends-for-agent work inside existing Python scripts?
- Yes. Install google-trends-for-agent globally with npm (Node.js 20+) and call gtfa snapshot, gtfa compare --format csv, or gtfa now from Python via subprocess to parse structured JSON or load CSV directly into pandas.read_csv().