Package Exports
- trendsmcp
Readme
trendsmcp
JavaScript/TypeScript client for the Trends MCP API. Query keyword trend time series and growth percentages across Google Search, YouTube, Reddit, Amazon, TikTok, Wikipedia, npm, Steam, and more — from a single endpoint.
100 requests/month free. No credit card. Get your key →
Install
npm install trendsmcpyarn add trendsmcppnpm add trendsmcpQuick start
import { TrendsMcpClient } from "trendsmcp";
const client = new TrendsMcpClient({ apiKey: "YOUR_API_KEY" });
// 5-year weekly time series
const series = await client.getTrends({
source: "google search",
keyword: "bitcoin",
});
// [{ date: "2026-03-21", value: 47, volume: 25853617, keyword: "bitcoin", source: "google search" }, ...]
// Growth across multiple periods
const growth = await client.getGrowth({
source: "google search",
keyword: "nike",
percent_growth: ["12M", "3M", "YTD"],
});
// { search_term: "nike", data_source: "google search", results: [...], metadata: {...} }Methods
getTrends(params)
Returns a historical time series for a keyword from a single source.
| Parameter | Type | Required | Description |
|---|---|---|---|
source |
TrendsSource |
Yes | Data source (see below) |
keyword |
string |
Yes | Keyword, brand, product, or topic |
data_mode |
"weekly" | "daily" |
No | "weekly" returns ~261 weekly points (5 years, default). "daily" returns the last 30 days. |
Response: Array of TrendsDataPoint objects:
interface TrendsDataPoint {
date: string; // ISO 8601 e.g. "2026-03-21"
value: number; // Normalized score, 0–100
volume: number | null; // Absolute volume where available
keyword: string;
source: string;
}Examples:
// Google Search — weekly
const weekly = await client.getTrends({
source: "google search",
keyword: "bitcoin",
});
// Reddit — daily granularity
const daily = await client.getTrends({
source: "reddit",
keyword: "AI agents",
data_mode: "daily",
});
// Amazon product demand
const amazon = await client.getTrends({
source: "amazon",
keyword: "standing desk",
});
// YouTube search volume
const yt = await client.getTrends({
source: "youtube",
keyword: "rust programming",
});
// npm weekly downloads
const pkg = await client.getTrends({
source: "npm",
keyword: "react",
});getGrowth(params)
Calculates point-to-point percentage growth for a keyword over one or more time windows.
| Parameter | Type | Required | Description |
|---|---|---|---|
source |
TrendsSource |
Yes | Data source |
keyword |
string |
Yes | Keyword, brand, or topic |
percent_growth |
Array<GrowthPreset | CustomGrowthPeriod> |
Yes | Periods to calculate |
data_mode |
"weekly" | "daily" |
No | Data granularity |
Growth presets: 7D 14D 30D 1M 2M 3M 6M 9M 12M 1Y 18M 24M 2Y 36M 3Y 48M 60M 5Y MTD QTD YTD
Custom date range:
interface CustomGrowthPeriod {
name?: string; // Optional label returned in results
recent: string; // More recent date, YYYY-MM-DD
baseline: string; // Baseline date, YYYY-MM-DD
}Response:
interface GetGrowthResponse {
search_term: string;
data_source: string;
results: GrowthResult[];
metadata: GrowthMetadata;
}
interface GrowthResult {
period: string;
growth: number; // Percentage change, positive or negative
direction: "increase" | "decrease";
recent_date: string;
baseline_date: string;
recent_value: number;
baseline_value: number;
volume_available: boolean;
recent_volume: number | null;
baseline_volume: number | null;
volume_growth: number | null;
}Examples:
// Preset periods
const growth = await client.getGrowth({
source: "google search",
keyword: "nike",
percent_growth: ["12M", "3M", "YTD"],
});
// Custom date comparison
const custom = await client.getGrowth({
source: "amazon",
keyword: "air fryer",
percent_growth: [
{ name: "holiday lift", recent: "2025-12-31", baseline: "2025-10-01" }
],
});
// Multiple sources in parallel
const [googleGrowth, redditGrowth] = await Promise.all([
client.getGrowth({ source: "google search", keyword: "typescript", percent_growth: ["1Y", "3Y"] }),
client.getGrowth({ source: "reddit", keyword: "typescript", percent_growth: ["1Y", "3Y"] }),
]);Data sources
Pass the exact string as source:
source |
Description |
|---|---|
"google search" |
Google search volume |
"google images" |
Google image search volume |
"google news" |
Google News search volume |
"google shopping" |
Google Shopping search volume |
"youtube" |
YouTube search volume |
"tiktok" |
TikTok hashtag volume |
"reddit" |
Reddit mention volume |
"amazon" |
Amazon product search volume |
"wikipedia" |
Wikipedia page views |
"news volume" |
News article mention volume |
"news sentiment" |
News sentiment score |
"npm" |
npm package weekly downloads |
"steam" |
Steam concurrent players (monthly) |
All values are normalized to a 0–100 relative scale.
Error handling
All API errors throw a TrendsMcpError:
import { TrendsMcpClient, TrendsMcpError } from "trendsmcp";
const client = new TrendsMcpClient({ apiKey: "YOUR_API_KEY" });
try {
const series = await client.getTrends({ source: "google search", keyword: "bitcoin" });
} catch (err) {
if (err instanceof TrendsMcpError) {
console.error(err.status); // HTTP status code, e.g. 429
console.error(err.code); // API error code, e.g. "rate_limited"
console.error(err.message); // Human-readable message
}
}| Status | Code | Meaning |
|---|---|---|
| 400 | missing_parameter |
Required field missing |
| 400 | invalid_source |
Unrecognized source value |
| 401 | Missing or invalid API key | |
| 404 | not_found |
No data for this keyword/source |
| 429 | rate_limited |
Monthly limit reached |
| 500 | internal_error |
Unexpected server error |
TypeScript support
Full types are included. No @types package needed.
import type {
TrendsSource,
GetTrendsParams,
GetTrendsResponse,
TrendsDataPoint,
GrowthPreset,
CustomGrowthPeriod,
GetGrowthParams,
GetGrowthResponse,
GrowthResult,
} from "trendsmcp";Links
License
MIT