pytrends is Dead: The Best Google Trends Alternatives in 2026
pytrends breaks constantly, the maintainer has stepped back, and the official Google Trends API is still not public. The alternatives that actually work in 2026.
The actor referenced in this article. Pay only for results delivered.
pytrends was a beloved Python library for accessing Google Trends data. It was unofficial (Google has no public Trends API), maintained by a single developer, and worked well enough for years. Today it is effectively dead.
TL;DR: pytrends hasn’t been meaningfully updated since 2022 and fails consistently on cloud servers because Google blocks datacenter IPs from widgetdata endpoints. Working alternatives: direct HTTP with a residential proxy, a managed Google Trends scraper at $0.004/keyword-report, or SerpAPI at $75/month for 5,000 searches. Google Keyword Planner gives absolute volumes for free.
Here is the current state of pytrends and every alternative worth considering.
What Happened to pytrends
pytrends works by reverse-engineering Google Trends’ internal API. The library has not had a meaningful update since 2022. GitHub issues report consistent 429 errors, empty data returns, and API format changes that the library does not handle.
The root technical problem: Google moved the widgetdata API behind datacenter IP blocking. pytrends runs from your local machine (residential IP) and may work interactively, but runs from cloud servers, which is where you actually want to use it, get blocked.
The library also does not handle Google’s XSSI prefix ()]}',\n) correctly in all cases, and the req= parameter encoding for newer Trends features has changed.
Where pytrends Still Works, and Where It Fails
pytrends is a library, not an API. Google publishes no Trends API and no contract, so whether pytrends works comes down to one thing: whether Google decides to serve your IP.
It is still fine in a few places:
- your laptop on a home connection
- a home server or Raspberry Pi on a residential ISP
- notebooks you run by hand for one-off research
- low volume, roughly under 50 queries a day
It fails almost everywhere you would schedule it. GitHub Actions runners fail close to 100% of the time. AWS (EC2, Lambda, Fargate), GCP (Compute Engine, Cloud Functions, Cloud Run), Azure and Heroku all sit on datacenter ranges Google knows well. A Docker container does not help, because its external IP is still the cloud provider’s. Any CI job or cron job on cloud infrastructure hits the same wall.
On those machines the error usually looks like this:
from pytrends.request import TrendReq
from pytrends.exceptions import TooManyRequestsError
pytrends = TrendReq(hl='en-US', tz=360)
pytrends.build_payload(['machine learning'], timeframe='today 12-m')
try:
df = pytrends.interest_over_time()
except TooManyRequestsError:
# fires on nearly every AWS, GCP or GitHub Actions run
print("Rate limited by Google")
Even from a home connection it throttles. Expect trouble after 50 to 100 queries in one session, and a practical ceiling of about 100 to 200 queries a day with sleeps between requests.
Patching pytrends with a residential proxy
If you want to keep your pytrends code, route it through a residential proxy and slow it down. pytrends takes a list of proxies plus retry settings, and it accepts at most 5 keywords per payload:
import time
from pytrends.request import TrendReq
from pytrends.exceptions import TooManyRequestsError
def get_trends_data(keywords, timeframe='today 12-m', geo='US'):
proxies = ['https://user:pass@proxy.example.com:8080']
pt = TrendReq(hl='en-US', tz=360, proxies=proxies, retries=5, backoff_factor=3)
results = []
for i in range(0, len(keywords), 5): # pytrends max is 5 keywords per payload
batch = keywords[i:i + 5]
pt.build_payload(batch, timeframe=timeframe, geo=geo)
try:
results.append(pt.interest_over_time())
time.sleep(10) # space out requests
except TooManyRequestsError:
time.sleep(60) # back off hard, this batch is skipped
return results
Bandwidth is not the expensive part. A Trends query uses roughly 50 to 200 KB. The cost is the monthly minimum on a residential plan, plus the time spent rotating flagged IPs and debugging proxy failures on top of Google’s own rate limits.
Alternative 1: Direct HTTP with Explore + Widgetdata
The architecture that actually works:
- Call
/trends/api/exploreto get widget tokens (no residential IP needed) - Call
/trends/api/widgetdata/*with those tokens using a residential proxy
This is not a public API: it is the same reverse-engineering approach as pytrends, done correctly.
import requests
import json
import re
import urllib.parse
def get_trends(keyword: str, timeframe: str = 'today 12-m', geo: str = 'US', proxy: str = None) -> dict:
session = requests.Session()
proxy_config = {'https': proxy} if proxy else None
# 1. Seed NID cookie
session.get('https://trends.google.com/trends/', proxies=None, timeout=10)
# 2. Get widget tokens (no proxy needed)
explore_params = {
'hl': 'en-US',
'tz': '-330',
'req': json.dumps({
'comparisonItem': [{'keyword': keyword, 'geo': geo, 'time': timeframe}],
'category': 0,
'property': '',
}),
'token': 'APP6_UEAAAAAZ...', # Not needed for explore
}
explore_url = 'https://trends.google.com/trends/api/explore'
resp = session.get(explore_url, params=explore_params, timeout=15)
# Strip XSSI prefix
data = json.loads(resp.text.lstrip(")]}',\n"))
widgets = data.get('widgets', [])
results = {}
# 3. Fetch each widget's data (requires residential proxy)
for widget in widgets:
widget_id = widget.get('id')
endpoint_map = {
'TIMESERIES': 'multiline',
'GEO_MAP': 'comparedgeo',
'RELATED_QUERIES': 'relatedsearches',
'RELATED_TOPICS': 'relatedsearches',
}
if widget_id not in endpoint_map:
continue
endpoint = endpoint_map[widget_id]
widget_url = f'https://trends.google.com/trends/api/widgetdata/{endpoint}'
widget_resp = session.get(
widget_url,
params={
'hl': 'en-US',
'tz': '-330',
'req': json.dumps(widget['request']),
'token': widget['token'],
},
proxies=proxy_config,
timeout=20,
)
widget_data = json.loads(widget_resp.text.lstrip(")]}',\n"))
results[widget_id] = widget_data
return results
Requires: A residential proxy for the widgetdata calls. Works from cloud infrastructure.
Alternative 2: Google Trends Pro (Managed)
Our Google Trends Pro actor implements the explore + residential widgetdata pattern with automatic proxy rotation. No proxy subscription required: Apify’s RESIDENTIAL pool is included.
from apify_client import ApifyClient
client = ApifyClient('YOUR_API_TOKEN')
run = client.actor('themineworks/google-trends-pro').call(run_input={
'keywords': ['python scraping', 'apify', 'bright data'],
'timeframe': 'today 12-m',
'geo': 'US',
'includeRelatedQueries': True,
'includeInterestByRegion': True,
})
for item in client.dataset(run['defaultDatasetId']).iterate_items():
if item.get('_type'): # skip the run summary and error records
continue
print(item['keyword'])
print(f" Peak interest: {max(p['value'] for p in item['interest_over_time'])}")
rising = item.get('related_queries', {}).get('rising', [])
print(f" Rising queries: {[r['query'] for r in rising[:3]]}")
Alternative 3: Google Keyword Planner (Absolute Volumes)
If you need absolute search volumes rather than relative trends indices, Google Keyword Planner (part of Google Ads) is the authoritative source. Requires a Google Ads account (free to create, no spending required).
The limitation: Keyword Planner gives monthly search volume estimates in ranges (1K-10K), not precise numbers, and only updates monthly.
Alternative 4: Third-Party SEO Tools
Ahrefs, Semrush, and Moz all provide keyword volume data from their own panel-based estimates. These are more accurate for absolute volumes than Google Trends, but cost $99-299/month.
For trend direction (rising vs declining), Google Trends remains more accurate than SEO tool estimates because it uses real Google search data rather than panel extrapolation.
Alternative 5: SerpAPI with Google Trends Endpoint
SerpAPI offers a Google Trends endpoint that abstracts the scraping layer. Pricing is per API call. The data quality matches direct Google Trends access.
import requests
params = {
'engine': 'google_trends',
'q': 'python scraping',
'date': 'today 12-m',
'api_key': 'YOUR_SERPAPI_KEY',
}
data = requests.get('https://serpapi.com/search', params=params).json()
Cost: SerpAPI charges $75/month for 5,000 searches. More expensive than direct access at scale.
Comparison Table
| Option | Monthly Cost | Requires Proxy | Maintenance | Reliability |
|---|---|---|---|---|
| pytrends (cloud) | Free | Yes | DIY | Low |
| Direct HTTP (correct) | Proxy cost only | Yes | DIY | High |
| Google Trends Pro | Usage-based | No | None | High |
| SerpAPI | $75+ | No | None | High |
| Google Keyword Planner | Free | No | None | Medium (absolute vol only) |
Which One to Use
Both routes hit the same widgetdata endpoints, so the data is identical. The difference is where the code runs and how much upkeep you want.
Stay with pytrends if you run scripts locally on a home connection, your volume is under about 100 queries a day, the work is exploratory, and a proxy plan is not in the budget. For 20 keywords checked weekly from a laptop, it is the right tool and it costs nothing.
Move to the direct HTTP approach or a managed scraper if the job runs anywhere in the cloud (GitHub Actions, AWS, GCP, Azure, Heroku), runs on a schedule, or covers hundreds of keywords a day. A daily monitor on 500 keywords is not a pytrends job. A pay-per-result scraper also charges nothing in months you do not use it, which a proxy subscription does not. For a full Python walkthrough of the managed route, including bulk exports, see Google Trends in Python.
Bottom Line
pytrends is not worth maintaining in 2026 for cloud usage. The direct HTTP approach works but requires a residential proxy subscription and maintenance when Google updates its API. For most developers, a managed solution is the practical choice: you pay a small per-query cost and get reliable data without any infrastructure work.
Frequently Asked Questions
Is pytrends still maintained in 2026?
pytrends has not received a meaningful update since 2022. The maintainer has effectively stepped back from the project. Current GitHub issues document consistent failures including 429 errors on cloud servers, empty data returns, and broken XSSI prefix handling. It is not recommended for production or any cloud-based deployment.
What replaced pytrends for production Google Trends data?
The most robust replacement is a direct HTTP implementation using Google’s explore/widgetdata endpoint pattern with a residential proxy for the widgetdata calls. Managed services like Google Trends Pro abstract this entirely. SerpAPI’s Google Trends endpoint costs $75/month for 5,000 searches. Google Keyword Planner provides absolute monthly volumes for free but not trend direction.
Why does Google Trends block datacenter IPs?
Google Trends blocks datacenter IP ranges (AWS, GCP, Azure) from accessing the widgetdata API endpoints where interest over time, related queries, and regional breakdowns live. The explore endpoint works from any IP to return widget tokens, but the actual data requests require a residential or mobile IP.
What does Google Trends Pro cost compared to pytrends plus a proxy?
pytrends is free but requires a residential proxy subscription ($30-100/month) to work reliably on cloud infrastructure. Google Trends Pro charges per keyword report, and failed results are never charged. For production workloads with 100-500 keywords per month, the managed option is cost-competitive with DIY costs once developer time is factored in.
Does Google Keyword Planner give the same data as Google Trends?
No. Google Keyword Planner gives monthly search volume estimates from Google Ads data, in ranges like 1K-10K per month. Google Trends gives relative search interest indexed 0-100 showing trend direction over time. Use Keyword Planner for absolute volumes; use Trends for understanding whether a topic is rising, declining, or seasonal.
Explore the scraper referenced in this article: inputs, outputs, and pricing, then run it on Apify.
Frequently asked questions
Is pytrends still working in 2026? +
pytrends works from residential IP addresses but fails consistently from cloud servers and Docker containers. Google blocks datacenter IP ranges from the widgetdata endpoints where actual trend data lives.
What is the best pytrends alternative in 2026? +
For production use, a managed scraper like Google Trends Pro handles the residential IP routing automatically. For light local use, pytrends with a residential proxy still works.
Why does pytrends return empty data arrays? +
Empty data usually means the widgetdata request was blocked by Google. The explore endpoint returns a 200 with widget tokens, but the downstream widgetdata calls return 429s from datacenter IPs.
Can I get Google Trends data without pytrends? +
Yes. The Google Trends Pro actor on Apify provides reliable trend data including interest over time, interest by region, and related queries without any proxy setup.
Does pytrends work on GitHub Actions or AWS Lambda? +
Rarely. GitHub Actions runners, Lambda, Cloud Run and other cloud environments use datacenter IPs that Google Trends rate-limits almost at once, so pytrends raises TooManyRequestsError on nearly every run. Route the requests through a residential proxy or use a managed scraper.
Google Trends API for Python in 2025: pytrends vs Scraper
Google Trends has no official API. Learn why pytrends breaks, how the SERP API approach works, and the fastest way to pull trend data into Python without getting rate-limited.
Using Google Trends Data for Market Research: A Developer's Playbook
How to turn Google Trends data into market research you can act on, from keyword validation to seasonal demand forecasting.
Using Google Trends to Find Untapped SEO Opportunities in 2025
A step-by-step framework for using Google Trends data to spot rising keywords before they get competitive.
ClinicalTrials.gov API v2: How to Search 600,000 Studies and Track Trial Status
How to use the ClinicalTrials.gov v2 REST API: what changed from v1, which filters actually exist, and Python for bulk pulls and status monitoring.