Python trends API

The most common Python approach to trend data is pytrends - an unofficial Google Trends scraper that works until it does not. Trends MCP is accessible via standard HTTP from any Python script, returns structured JSON with absolute volume estimates and data quality scores, covers 15+ sources, and does not break when Google updates its frontend. No SDK required, no special library, just an HTTP call with an Authorization header.

Python developers who need trend data have historically had one main option: pytrends. It is free, widely documented, and integrates well with pandas. It is also an unofficial scraper built on reverse-engineered Google Trends endpoints, which means its status as a reliable production dependency is always conditional.

Trends MCP is a different approach. It is a managed HTTP API with a consistent JSON schema, no scraping, absolute volume estimates, and 15+ data sources. From Python, calling it requires nothing more than the requests library.

The pytrends reliability problem

pytrends has been widely used since 2015. The problem is not that it fails often - it works fine most of the time. The problem is the failure mode when it does break.

Google updates its Trends frontend 1-4 times per year in ways that break pytrends. When this happens, every pipeline using pytrends starts returning errors overnight, with no warning. The fix depends on the open-source community identifying the change, writing a patch, merging it, and releasing a new version. This process has historically taken anywhere from a few days to several weeks, depending on the severity of the change and maintainer availability.

For a research notebook, waiting a week for a fix is inconvenient. For a production pipeline that feeds a dashboard or a model, it is a hard outage. Trends MCP is a managed service - infrastructure issues are handled on the provider side.

Calling Trends MCP from Python

The endpoint is a standard HTTPS URL accepting POST requests with JSON-RPC bodies. Authentication is an Authorization Bearer header with your Trends MCP API key.

import requests

API_KEY = "your_api_key"
ENDPOINT = "https://api.trendsmcp.ai/mcp"

def call_trends_mcp(tool_name: str, params: dict) -> dict:
    payload = {
        "jsonrpc": "2.0",
        "method": "tools/call",
        "params": {
            "name": tool_name,
            "arguments": params
        },
        "id": 1
    }
    response = requests.post(
        ENDPOINT,
        json=payload,
        headers={"Authorization": f"Bearer {API_KEY}"}
    )
    return response.json()

result = call_trends_mcp("get_trends", {
    "keyword": "large language models",
    "source": "google",
    "data_mode": "weekly"
})

The response follows the MCP JSON-RPC schema. The actual trend data is inside result["result"]["content"][0]["text"], which is a JSON string that you parse to get the time series array.

Building a pandas DataFrame from get_trends

Once you have the time series, loading it into pandas is straightforward:

import json
import pandas as pd

trend_json = json.loads(result["result"]["content"][0]["text"])
time_series = trend_json.get("data", [])

df = pd.DataFrame(time_series)
df["date"] = pd.to_datetime(df["date"])
df = df.set_index("date")

The data_quality_score column is worth using immediately. Filtering out rows where data_quality_score < 0.4 removes low-confidence data points before any analysis, which is better than discovering them as outliers later.

Multi-source growth comparison

get_growth with multiple sources in a single call returns all platform growth rates at once. This is the most efficient pattern for building cross-platform feature sets:

growth_result = call_trends_mcp("get_growth", {
    "keyword": "electric vehicles",
    "source": "google, tiktok, reddit, amazon, youtube",
    "percent_growth": ["1M", "3M", "6M", "1Y"]
})

growth_data = json.loads(growth_result["result"]["content"][0]["text"])

One request, five sources, four time periods each. The equivalent in pytrends would require five separate Google Trends calls, scraping a different site for Reddit and TikTok, and manual normalization before any comparison was valid.

For AI agent frameworks

For Python AI agent frameworks that support MCP (LangChain, CrewAI, PydanticAI, AutoGen), Trends MCP integrates as a tool definition. The agent can call get_trends, get_growth, get_ranked_trends, and get_top_trends in response to natural language instructions - no custom wrapper code required once the MCP connection is configured.

For frameworks that use MCP tool definitions natively, the server URL is https://api.trendsmcp.ai/mcp with HTTP transport. The tool schemas are exposed via the MCP tools/list endpoint.

get_trends

Retrieve a full 5-year weekly time series for any keyword and source - returns a JSON array of date/value/volume objects ready for pandas DataFrame construction.

get_trends(keyword='electric vehicles', source='google', data_mode='weekly')

get_growth

Compute period-over-period growth rates for any keyword across multiple sources in one call - returns a flat dict of source: {growth_rate, start_volume, end_volume} for direct use as model features.

get_growth(keyword='electric vehicles', source='google, tiktok, reddit, amazon', percent_growth=['1M', '3M', '1Y'])

get_ranked_trends

Retrieve ranked lists of the fastest-growing keywords on any platform - useful for generating keyword candidate sets without manual curation.

get_ranked_trends(source='google', sort='yoy_pct_change', limit=50)

get_top_trends

Pull what is trending right now with no seed keyword - for pipelines that need to capture current trending topics on a schedule.

get_top_trends(type='TikTok Trending Hashtags', limit=30)

Common questions

pytrends is an unofficial library that reverse-engineers the Google Trends web interface. It has worked for years, but it has three persistent problems for Python developers: reliability (it breaks when Google changes its frontend, typically multiple times per year, requiring a community patch you wait for), data quality (returns relative 0-100 values only, not absolute volume, making keyword-to-keyword comparisons statistically unreliable without additional calibration), and rate limits (Google aggressively rate-limits the scraping IP, producing 429 errors at moderate query volumes that require exponential backoff logic). For one-off notebook queries, these are manageable. For production pipelines, they are not.
Trends MCP is accessible via standard HTTPS POST requests with an Authorization header containing your API key. The request body is JSON-RPC formatted, and the response is structured JSON. No SDK, no MCP library, no special setup - just the requests library and an API key from trendsmcp.ai. The response schema is consistent and documented, so it integrates directly into pandas workflows or any data pipeline.
Trends MCP does not currently have a Python-specific SDK. The HTTP API is designed to be simple enough that an SDK is not necessary - the requests library plus a simple wrapper function covers all four tools. For AI-agent workflows in Python frameworks like LangChain or CrewAI, Trends MCP integrates via MCP tool definitions, which those frameworks support natively.
Data science notebooks that need multi-source trend time series for analysis or modeling. ETL pipelines that collect weekly trend data for dashboards or databases. Research scripts comparing trend signals across Google, TikTok, Reddit, and other sources. AI agent frameworks (LangChain, CrewAI, PydanticAI) where trend data is one tool the agent can call. Any Python workflow that currently uses pytrends and needs reliability, absolute volume, or multi-platform coverage.
Get Python trends API in 30 seconds
Free tier includes 100 requests per month. No credit card required. Works with Claude, Cursor, ChatGPT, Raycast, and every MCP client.
Get your free API key