mcpField
G
Google Trends API

Google Trends API

リモート
trendsapi.aiデータ・分析010 週間前に更新
リポジトリ公式サイト

Google Trends API について

Google Trends APIは、Google Trendsの検索関心データを取得するPythonクライアントです。0~100の標準化スコア、履歴、成長指標を備え、PythonやJavaScript/TypeScriptで検索トレンドを分析する開発者向けです。

主な機能

  1. 01キーワードの時系列データを取得
  2. 02複数期間の成長指標を計算
  3. 03リアルタイムのトレンド順位を取得
  4. 04PythonとJavaScriptのクライアント

活用シーン

  1. 01キーワード検索関心の推移を分析
  2. 02期間別の検索関心の成長を比較
  3. 03Pandasデータセットにトレンドデータを整形

設定

リモートサーバーはインストール不要です。クライアントを選んで設定をコピーするか、ワンクリックで導入できます。

エンドポイントhttps://google-trends.api.trendsapi.ai/mcp
インストールコマンドをコピー
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

コマンドはターミナルで実行し、JSON は各クライアントの MCP 設定に貼り付けて再起動します。認可が必要なサーバーは初回接続時にログインを求めます。

すべてのエンドポイント
Streamable HTTPhttps://google-trends.api.trendsapi.ai/mcp認証が必要

ツール

詳細

Google Trends API

Trends API 経由で Google Trends データを取得する Python クライアントです。0~100 の正規化スコア、履歴と成長率を取得でき、無料枠があります。スクレイパーではありません。

License: MIT PyPI Python npm

キーはこちら:trendsapi.ai/#get-key。HTTP の仕様とすべてのソースはこちら:trendsapi-ai/trendsapi。

認証

pip install google-trends-client
export TRENDSAPI_KEY=your_key

Python 3.9 以降。同じキーを HTTP API で使用します。

from google_trends_client import TrendsAPI

client = TrendsAPI()                    # TRENDSAPI_KEY
# client = TrendsAPI(api_key="YOUR_KEY")

キーワードヘルパーのデフォルトは source: "google search" です。source= を渡すと、同じクライアントでほかのプラットフォームにもアクセスできます。公式の完全なクライアント(すべてのソースに対応、プリセットなし):trendsapi。

メソッド

メソッドREST mode戻り値
get_time_series(keyword, source=, data_mode=)get_time_serieslist[TrendsDataPoint]
get_growth(keyword, percent_growth=, source=, data_mode=)get_growthGetGrowthResponse
get_live(limit=, offset=, category=)get_top_trendsGetTopTrendsResponse
get_top_trends(type=, ...)get_top_trendsGetTopTrendsResponse

source は小文字です(google search)。type は正確な表記を使います(Google Trends)。これらを混在させると 400 エラーになります。

from google_trends_client import TrendsAPI

client = TrendsAPI()                    # TRENDSAPI_KEY
# client = TrendsAPI(api_key="YOUR_KEY")

series = client.get_time_series("heat pump")
print(series[-1].date, series[-1].value)

growth = client.get_growth("heat pump", percent_growth=["3M", "12M"])
print(growth.results[0].growth, growth.results[0].direction)

hot = client.get_live(limit=10)
print(hot.data)                         # [[1, "..."], ...]

get_time_series

points = client.get_time_series("heat pump")

各ポイント:

フィールド常に存在意味
dateはいYYYY-MM-DD
valueはいこの系列の 0~100 の指数
keywordはいエコー
volumeいいえ利用可能な場合の絶対ボリューム
source or datatypeいいえパイプラインのラベル

Python では list[TrendsDataPoint] が返されます。["date"] ではなく .date と .value を使用してください。 JS では同じフィールドがオブジェクトのプロパティとして返されます。

get_growth

g = client.get_growth("heat pump", percent_growth=["12M", "3M", "YTD"])
print(g.results[0].growth, g.results[0].direction)

percent_growth のデフォルト値:["12M"]。プリセット:7D 14D 30D 1M 2M 3M 6M 9M 12M/1Y 18M 24M/2Y 36M/3Y 48M 60M/5Y MTD QTD YTD。カスタム値:{"name": "Launch", "recent": "2024-06-01", "baseline": "2024-01-01"}。

フィールド意味
search_termキーワード
data_sourceソース
results期間ごとに 1 つのオブジェクト(period、growth、direction、日付、値)
metadata件数/成功フラグ

複数の期間を指定しても、リクエスト数は 1 件です。Python:growth.results[0].growth。JS:growth.results[0].growth。

get_live

hot = client.get_live(limit=10)
フィールド意味
as_of_tsスナップショット時刻
typeフィード名
limit, offset, countページネーション
data[rank, label] の行

Python:hot.data。JS:hot.data。offset= と category= はオプションです(Amazon Best Sellers by Category、Top Websites のみ)。

非同期

import asyncio
from google_trends_client import AsyncTrendsAPI

async def main():
    c = AsyncTrendsAPI()
    return await asyncio.gather(
        c.get_time_series("heat pump"),
    )

asyncio.run(main())

各 200 レスポンスは課金対象のリクエスト 1 件です。

Pandas

from dataclasses import asdict
import pandas as pd
from google_trends_client import TrendsAPI

df = pd.DataFrame(asdict(p) for p in TrendsAPI().get_time_series("heat pump"))
df["date"] = pd.to_datetime(df["date"])
print(df.set_index("date")["value"].resample("ME").mean().tail())

JavaScript / TypeScript

npm install google-trends-js

Node 18 以降、Deno、Bun、Workers に対応しています。同じ API キーを使用します。上記のフィールド一覧が適用されます。

google-trends-node、google-trends-client としても公開されています。同じクライアントで、パッケージ名が異なります。

メソッド
メソッドREST mode戻り値
getTimeSeries(keyword, { source, data_mode })get_time_series週次ポイント
getGrowth(keyword, { percent_growth, source, data_mode })get_growth成長率オブジェクト
getLive({ limit, offset, category })get_top_trendsライブフィード
getTopTrends({ type, ... })get_top_trendsライブフィード
import { TrendsAPI } from "google-trends-js";

const client = new TrendsAPI({ apiKey: process.env.TRENDSAPI_KEY! });
const series = await client.getTimeSeries("heat pump");
console.log(series.at(-1)?.date, series.at(-1)?.value);

const growth = await client.getGrowth("heat pump", {
  percent_growth: ["3M", "12M"],
});
console.log(growth.results[0].growth, growth.results[0].direction);

const live = await client.getLive({ limit: 10 });
console.log(live.data);                 // [[1, "..."], ...]

呼び出し(curl)

フィールド値
エンドポイントPOST https://api.trendsapi.ai/api
認証Authorization: Bearer $TRENDSAPI_KEY
履歴get_time_series または get_growth と source: google search
キーワード任意の語句。例:heat pump
ライブの typeGoogle Trends
curl -sS -X POST https://api.trendsapi.ai/api \
  -H "Authorization: Bearer $TRENDSAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mode":"get_time_series","source":"google search","keyword":"heat pump"}'

ソースに関する注意事項

  • 関連ソース(同じエンドポイントで、source が異なります):google images、google news、google shopping。
  • value は、Google ウェブ検索におけるこの検索語の値を 0~100 で示したもので、広告のインプレッション数ではありません。

エラー

HTTPクライアント
200ペイロードを解析しました。Python のデータクラス/JS の型付きオブジェクト
400例外が発生します。source または type のスペルを修正してください
401例外が発生します。TRENDSAPI_KEY を確認してください
404例外が発生します。このキーワードの系列はありません。再試行しないでください
429例外が発生します。クォータ
5xxクライアントが再試行した後、例外が発生します

HTTP の body フィールドは JSON 文字列です。SDK はこれをデコードします。生の curl では body をもう一度解析する必要があります。

サイト:https://trendsapi.ai/trends/google-trends。

ライセンス

MIT。LICENSE を参照してください。

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。