Trends API for JavaScript

JavaScript has no equivalent of pytrends - there is no widely-used unofficial Google Trends library for Node.js that has maintained community trust. Trends MCP fills the gap directly: it is accessible via standard fetch from any JavaScript environment (Node.js, browser, edge runtime, serverless function) and returns structured JSON with normalized values and absolute volume estimates from 15+ sources.

Python developers have pytrends. JavaScript developers have a gap. The few npm packages that attempt Google Trends scraping have poor maintenance records and no community consensus around reliability. The standard approach for JavaScript projects that need trend data has been to either use a Python microservice for data collection or to accept Google Trends' manual interface and not automate it.

Trends MCP is a managed HTTP API that works from any JavaScript environment via fetch. The response is structured JSON with a consistent schema, which makes it straightforward to use in web apps, API routes, serverless functions, or AI agent tools.

Calling Trends MCP from Node.js

The API accepts standard HTTPS POST requests with JSON-RPC bodies. Node.js v18+ includes native fetch, so no additional HTTP library is required:

const API_KEY = process.env.TRENDS_MCP_API_KEY;
const ENDPOINT = "https://api.trendsmcp.ai/mcp";

async function callTrendsMCP(toolName, params) {
  const response = await fetch(ENDPOINT, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${API_KEY}`,
    },
    body: JSON.stringify({
      jsonrpc: "2.0",
      method: "tools/call",
      params: {
        name: toolName,
        arguments: params,
      },
      id: 1,
    }),
  });

  const data = await response.json();
  // The trend data is in the MCP response content
  return JSON.parse(data.result.content[0].text);
}

// Get weekly Google Search trend for any keyword
const trendData = await callTrendsMCP("get_trends", {
  keyword: "electric vehicles",
  source: "google",
  data_mode: "weekly",
});

The returned trendData object contains the time series array with date, normalized_value, absolute_volume_estimate, and data_quality_score per data point. Pipe it directly into a chart library.

Next.js API route pattern

For Next.js applications, the cleanest pattern is a route handler that proxies requests to Trends MCP, keeping the API key server-side:

// app/api/trends/route.js
export async function POST(request) {
  const { keyword, source } = await request.json();

  const trendData = await callTrendsMCP("get_growth", {
    keyword,
    source: source || "google, tiktok, reddit",
    percent_growth: ["1M", "3M", "1Y"],
  });

  return Response.json(trendData);
}

Your frontend components then call /api/trends and never touch the Trends MCP API key directly.

Building a trend feed with get_top_trends

For apps that surface what is trending right now, get_top_trends requires no keyword and returns a live list of trending topics on any platform:

const trendingNow = await callTrendsMCP("get_top_trends", {
  type: "TikTok Trending Hashtags",
  limit: 20,
});

// Map the results directly to UI components
const feed = trendingNow.trends.map((item) => ({
  name: item.name,
  value: item.normalized_value,
  growth: item.growth_rate,
}));

This works in serverless functions that run on a cron schedule to populate a cached trending feed, or in real-time API routes that serve a live feed component.

For AI agent tools in JavaScript

JavaScript AI frameworks can use Trends MCP as a tool definition. For Vercel AI SDK:

import { tool } from "ai";
import { z } from "zod";

const getTrends = tool({
  description: "Get trend data for a keyword across multiple platforms",
  parameters: z.object({
    keyword: z.string(),
    source: z.string().optional().default("google"),
    data_mode: z.enum(["weekly", "daily"]).optional().default("weekly"),
  }),
  execute: async ({ keyword, source, data_mode }) => {
    return await callTrendsMCP("get_trends", { keyword, source, data_mode });
  },
});

The tool is then passed to the AI model alongside other tools, and the model calls it automatically when a user asks about trends.

For direct MCP protocol support in Node.js, the MCP TypeScript SDK (@modelcontextprotocol/sdk) can connect to Trends MCP via HTTP transport at https://api.trendsmcp.ai/mcp. This is the most direct integration path for custom MCP clients built in TypeScript.

Edge runtime compatibility

Trends MCP works in edge runtimes (Cloudflare Workers, Vercel Edge Functions) with no modifications. The API uses standard HTTPS and JSON - no Node.js-specific APIs, no streaming that requires special handling. Call it with the standard fetch API and parse the response.

One edge consideration: API key management. Environment variables on Cloudflare Workers and Vercel Edge Functions work the same way as in Node.js. Store the key as a secret, reference it in the handler.

get_trends

Retrieve a full historical time series for any keyword - returns a JSON array of date/value/volume objects usable directly in chart libraries like Chart.js, D3, or Recharts.

get_trends(keyword='artificial intelligence', source='google', data_mode='weekly')

get_growth

Get cross-platform growth rates for scorecard or badge components - one call returns all sources with period-over-period growth percentages.

get_growth(keyword='artificial intelligence', source='google, tiktok, reddit', percent_growth=['1M', '3M', '1Y'])

get_ranked_trends

Power discovery UIs or trend feeds - returns ranked lists of fastest-growing keywords on any platform without a seed keyword.

get_ranked_trends(source='tiktok', sort='wow_pct_change', limit=20)

get_top_trends

Build real-time trending feeds - what is trending right now on any platform, no keyword required, ready for display.

get_top_trends(type='Google Trending Hashtags', limit=15)

Common questions

No reliable equivalent of pytrends exists for JavaScript. There are a few npm packages that attempt to scrape Google Trends, but none have the adoption, maintenance, or community support that pytrends has in Python - and pytrends itself has reliability problems. Most JavaScript developers who need programmatic trend data either call a managed API (like Trends MCP) or use a Python backend for the data collection layer.
Any environment with fetch or an HTTP client. This includes Node.js (v18+ has native fetch), browser (standard fetch API), edge runtimes (Cloudflare Workers, Vercel Edge, Deno Deploy), serverless functions (AWS Lambda, Google Cloud Functions, Vercel Functions), and any JavaScript framework (Next.js API routes, Remix loaders, Express endpoints). The API is standard HTTPS with no JavaScript-specific dependencies.
Technically yes - the API accepts CORS requests - but calling it from a browser exposes your API key to anyone viewing the page source. For browser applications, the recommended pattern is to proxy the request through a backend API route that holds the API key server-side. In Next.js, this is a route handler in /app/api/. In a standard Node.js server, it is a simple Express endpoint. The actual call to Trends MCP happens server-side; the frontend calls your proxy.
JavaScript AI frameworks that support MCP tools (Vercel AI SDK, LangChain.js, the Anthropic SDK with tool use) can call Trends MCP tools directly via the MCP protocol or via standard HTTP tool definitions. For Vercel AI SDK, define a tool that POSTs to the Trends MCP endpoint and returns the structured JSON result. For direct MCP protocol support in Node.js, use the MCP TypeScript SDK and point it at https://api.trendsmcp.ai/mcp with HTTP transport.
Get Trends API for JavaScript 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