Skip to content
Python Error Rescue · HTTP 429 Fix6 min read·Updated 2026-11-15·Verified Nov 2026 (GeneralMills/pytrends Archived Repo ↗)

How to Fix pytrends HTTP 429 Too Many Requests in Python (2026)

Quick Answer (BLUF)

pytrends throws HTTP 429 because Google Trends blocks unauthenticated cloud/datacenter IPs on trends.google.com/trends/api/explore, and GeneralMills archived pytrends in April 2025. Native workarounds (backoff_factor, manual NID cookies, residential proxies) either crash on urllib3 >= 2.0 or fail within 15–30 batch requests. For production Python pipelines, call SearchData API (GET /v1/trends & /v1/trends/realtime) for normalized JSON from $0.20/1K calls with zero 429 errors and 12,000 free credits.

Gateway p50 Latency28ms warm cache · <80ms suggest · ~1.1s live
Concurrency & Rate Limit30 – 600 RPM (Dedicated 1,200+ RPM Pool)
Deterministic Unit Price$0.08–$0.20 / 1,000 queries

Instant API key in 5s (12,000 Free Credits + 20,000 Sandbox Streak Credits) · $1 = 10,000 Credits · $9 Indie Starter Pack · Top up anytime via 0%-fee Multi-Chain Crypto (+5% bonus credits)

Primary-Source GitHub Maintainer Citation & Archive Status

“Looking for maintainers! Please open an issue with a method of contacting you if you're interested in becoming a maintainer. Unofficial API for Google Trends — allows simple interface for automating downloading of reports from Google Trends.”

— GeneralMills/pytrends Official GitHub README (Archived Read-Only) (retrieved 2026-11-15)

Because GeneralMills archived pytrends as read-only in April 2025, changes to Google's /trends/api/explore widget token handshake, NID session cookies, and urllib3 v2 Retry parameters are no longer patched upstream.

Instant Quickstart · Copy & Run in 30 Seconds

Drop-In pytrends Replacement — Zero HTTP 429 in Python & cURL

import pandas as pd
import requests

API_KEY = "sr_live_your_api_key"  # 12,000 free credits on signup (no card)

# Replaces TrendReq().build_payload(["ai agents"], geo="US") + interest_over_time()
resp = requests.get(
    "https://api.searchdataapi.com/v1/trends",
    params={"keyword": "ai agents", "country": "US"},
    headers={"x-api-key": API_KEY},
    timeout=20,
)
resp.raise_for_status()
payload = resp.json()["data"]

df = pd.DataFrame(payload["timeline"])
print(f"Summary: {payload['summary']} | Rows: {len(df)}")
print(df[["date_from", "value"]].tail(5))

Key Engineering Takeaways (TL;DR)

  • ✓Cloud ASNs (AWS EC2/Lambda, Hetzner, GCP, DigitalOcean, GitHub Actions) hit HTTP 429 on the very first trends.google.com/trends/api/explore token handshake.
  • ✓Passing retries=3, backoff_factor=0.5 in pytrends 4.9.2 raises TypeError: Retry.__init__() got an unexpected keyword argument 'method_whitelist' on urllib3 >= 2.0.
  • ✓Manual NID browser cookies expire or rotate within ~15–25 sequential keyword lookups, breaking unattended cron pipelines.
  • ✓SearchData API (GET /v1/trends & GET /v1/trends/realtime) delivers 54-week 0–100 timelines and live trending breakouts from $0.20/1K calls with 0% 429 rate and 0 charge on empty responses.

1. Why pytrends Immediately Returns Code 429 on AWS, Hetzner & GCP

Unlike a true REST API, pytrends scrapes internal browser widget endpoints on trends.google.com in a two-hop token sequence.

  • Step 1 Token Handshake Block (/trends/api/explore): Every TrendReq.build_payload() call first hits https://trends.google.com/trends/api/explore to mint short-lived widget tokens for /trends/api/widgetdata/multiline. Datacenter subnets without a valid browser NID cookie and residential TLS fingerprint receive HTTP 429 before a single data point is returned.
  • urllib3 >= 2.0 Retry Crash (method_whitelist Removed): When developers enable TrendReq(retries=3, backoff_factor=0.5), pytrends 4.9.2 passes the removed method_whitelist parameter to urllib3.util.retry.Retry, crashing immediately unless urllib3 is pinned below 2.0 or monkey-patched.
  • Archived Upstream Repository (April 2025): GeneralMills officially archived the pytrends repository as read-only, leaving broken trending_searches(pn='united_states') endpoints and cookie consent walls unpatched.

2. 3 Native pytrends Workarounds (and Where Each Breaks)

If you only need a one-off notebook check for 3 keywords on a home Wi-Fi connection, native mitigations can temporarily delay HTTP 429. For automated cron jobs or cloud workers, all three hit hard ceilings:

  • Workaround A — urllib3 Monkey-Patch + Exponential Backoff: Subclassing Retry to map method_whitelist -> allowed_methods fixes the TypeError, and sleeping 15–60s between calls helps on residential IPs. Limitation: Cloud/VPS IPs (AWS, Hetzner, GCP) are ASN-flagged on request #1, so sleeping 60 seconds still yields 429.
  • Workaround B — Browser NID Cookie Pre-Warming: Exporting a fresh NID=... header from Chrome DevTools into requests_args={'headers': {'Cookie': 'NID=...'}} bypasses the initial consent gate. Limitation: Google rotates and invalidates static NID cookies after roughly 15–30 automated bursts, silently breaking midnight ETL jobs.
  • Workaround C — Rotating Residential Proxies: Routing TrendReq(proxies=['https://user:pass@proxy:port']) through residential IPs avoids datacenter ASN blocks. Limitation: Residential bandwidth costs $8–$15/GB, and rotating mid-session between /explore and /widgetdata/multiline invalidates the widget token, causing 15–30% retry waste.
Comparison of 3 native pytrends HTTP 429 mitigations vs SearchData API
ApproachSearchData API (/v1/trends)backoff_factor + SleepNID Cookie Pre-WarmDIY Residential Proxies
AWS / Hetzner / GCP Reliability99.95% (Zero 429)Fails on cloud ASNsBreaks when cookie expires70–85% (token mismatch)
Throughput & Speed28ms warm · ~1.5s live (up to 600 RPM)1 query / 30–60s< 25 queries / session3–6s multi-hop latency
urllib3 v2 / Python 3.12+ SupportStandard requests / httpxRequires monkey-patchFragile manual headersSSL / proxy timeout loops
Unit Cost per 1,000 Queries$0.20 Realtime · $1.00 54w ($0.40 Scale)$0 (local laptop only)$0 + manual upkeep$8–$15/GB bandwidth

3. Permanent Fix: Replace pytrends with GET /v1/trends in 10 Lines of Python

Drop brittle browser cookies and proxy pools. Query GET /v1/trends (54-week 0–100 interest_over_time curve, 10 Credits) or GET /v1/trends/realtime (live surging breakouts, 2 Credits = $0.20/1K) directly over HTTPS with deterministic Pandas DataFrame output.

Drop-In pytrends Replacement — Zero HTTP 429 in Python & cURL

GET /v1/trends maps directly to a 54-week 0–100 timeline; GET /v1/trends/realtime streams country breakouts at $0.20/1K calls (0 Credits on error/empty).

# 1) 54-Week Interest Over Time Curve (replaces pytrends.interest_over_time())
curl -sS "https://api.searchdataapi.com/v1/trends?keyword=ai+agents&country=US" \
  -H "x-api-key: sr_live_your_api_key"

# 2) Realtime Trending Breakouts — $0.20 / 1K (replaces pytrends.trending_searches())
curl -sS "https://api.searchdataapi.com/v1/trends/realtime?country=US&limit=20" \
  -H "x-api-key: sr_live_your_api_key"
Test all 6 endpoints interactively in your browser:Open Live 6-Endpoint Playground →

Interactive Telemetry Workbench · GET /v1/trends/interest

Verify real-time latency, credit math & JSON schema

5,000 SERPs/day
2,500 news/day
500 curves/day
HTTP Calls / Day
8,000
Up to 600 RPM
Credit Unit
$1 = 10,000
Unified across 6 routes
Empty Result Fee
0 Credits
$0.00 for 0 matches
Estimated Monthly Pipeline Cost (30 Days)
$24.00/ mo on Scale ($30.60 on Growth)
Monthly consumption: 600,000 Credits (20,000 Credits/day)
SearchData API (Scale $0.08/1K):$24.00 / mo
SerpApi Developer Rate ($15/1K):$3600.00 / mo
Empty search / error fee:$0.00 (0 Credits)

Frequently Asked Questions

Why does pytrends fail with ResponseError: The request failed: Google returned a response with code 429?
pytrends scrapes internal Google Trends browser widgets (/trends/api/explore). Google rate-limits datacenter IPs (AWS, Hetzner, GCP, Azure) and requests lacking fresh NID session cookies, returning HTTP 429 before issuing widget tokens.
Why does TrendReq(retries=3, backoff_factor=0.5) throw TypeError: method_whitelist in Python?
pytrends 4.9.2 passes method_whitelist to urllib3's Retry class, which was removed in urllib3 2.0 in favor of allowed_methods. Switching to SearchData API uses standard requests or httpx with zero legacy dependency pins.
How much does SearchData API cost compared to running proxies for pytrends?
Realtime trending queries (GET /v1/trends/realtime) cost 2 Credits ($0.20 per 1,000 calls, or $0.08/1K on Scale), and 54-week historical curves (GET /v1/trends) cost 10 Credits ($1.00/1K base, $0.40/1K Scale). Every new account gets 12,000 free credits ($1.20) instantly with Google OAuth or email — no credit card required.

Zero 429 Rate Limits · Instant Production Key

Test live in the Playground or mint your sr_live_ key with 1-Click Google OAuth

Every new account receives 12,000 free Credits ($1.20) at 0ms plus up to +20,000 Sandbox Streak Credits — no credit card required, 0 Credits charged on empty or failed requests.