The API is one POST to https://api.trendsapi.ai/api. An SDK is optional. Official packages exist for Python (pip install trendsapi) and JavaScript (npm install trendsapi). They map to the three REST modes and decode the string body so callers never see the envelope. Every other language sends the same JSON with an HTTP client. The contract, including the second parse, is on the API reference. Exact source and type strings are on the sources reference.

Published clients

Language Install Repository
Python 3.9+ pip install trendsapi trendsapi-ai/TrendsAPI-py
JavaScript / TypeScript npm install trendsapi trendsapi-ai/trendsapi-js

Both packages read TRENDSAPI_KEY. The Python constructor also accepts api_key=. The JavaScript constructor accepts { apiKey }. Method names follow the REST mode values. Python keeps snake_case. JavaScript uses camelCase.

Python:

from trendsapi import TrendsAPI

client = TrendsAPI()
weekly = client.get_time_series(source="google search", keyword="bitcoin")
growth = client.get_growth(source="tiktok", keyword="bitcoin", percent_growth=["3M", "12M"])
board = client.get_top_trends(type="Google Trends", limit=10)

JavaScript:

import { TrendsAPI } from "trendsapi";

const client = new TrendsAPI({ apiKey: process.env.TRENDSAPI_KEY });
const weekly = await client.getTimeSeries({ source: "google search", keyword: "bitcoin" });
const growth = await client.getGrowth({ source: "tiktok", keyword: "bitcoin", percentGrowth: ["3M", "12M"] });
const board = await client.getTopTrends({ type: "Google Trends", limit: 10 });

These snippets match the published READMEs on PyPI and npm. They are not a live pull. A 200 from any method counts as one request. Current caps sit on pricing.

Raw HTTP, any language

curl, Go, PHP, Ruby, R, Java, and a notebook cell all post the same body. The header is Authorization: Bearer <api_key>. Content-Type is application/json.

POST https://api.trendsapi.ai/api
Authorization: Bearer <api_key>
Content-Type: application/json

{"mode":"get_growth","source":"google search","keyword":"bitcoin","percent_growth":["3M","12M"]}

The HTTP JSON looks like {"statusCode": 200, "body": "..."}. body is a string. Parse it before reading results or weekly points. Official SDKs hide that step. Raw clients must not skip it.

Python without the package:

import json, requests

res = requests.post(
    "https://api.trendsapi.ai/api",
    headers={"Authorization": "Bearer <api_key>"},
    json={"mode": "get_time_series", "source": "google search", "keyword": "bitcoin"},
)
payload = res.json()
data = json.loads(payload["body"]) if isinstance(payload.get("body"), str) else payload

get_trends is an alias of get_time_series on REST. Prefer get_time_series.

MCP instead of an SDK

The same key serves an MCP server at https://api.trendsapi.ai/mcp. Assistants that speak MCP call get_time_series, get_growth, and get_top_trends without an HTTP client in the repo. A mcp.json entry:

{
  "mcpServers": {
    "trends-api": {
      "url": "https://api.trendsapi.ai/mcp",
      "headers": { "Authorization": "Bearer YOUR_API_KEY" }
    }
  }
}

Setup notes sit on the docs MCP section. This is the product MCP endpoint, not a second product.

Languages that will get their own pages

This page is the parent. Child pages will show one client each: Python requests, httpx, generic JavaScript, Node, curl, pandas, R, Go, PHP, and Ruby. Until those URLs exist, copy the raw POST above. Do not invent extra first-party packages for those languages. If a community wrapper appears, treat it as unofficial until it lives under the trendsapi-ai GitHub org or the trendsapi package name on PyPI or npm.