mcpField
W
Wikipedia Trends API

Wikipedia Trends API

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

Wikipedia Trends API について

Wikipedia Trends APIは、Wikipediaの記事やトピックへの注目度を調べるAPIとPythonクライアントです。履歴データ、期間別の成長率、リアルタイムの人気ページを取得できます。

主な機能

  1. 01Wikipediaの注目度履歴を取得
  2. 02期間別の成長率を計算
  3. 03リアルタイムの人気ページを取得
  4. 04同期・非同期クライアントに対応

活用シーン

  1. 01Wikipediaページの注目度の変化を追跡
  2. 02期間ごとの成長率を比較
  3. 03現在人気のWikipediaページを確認

設定

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

エンドポイントhttps://wikipedia.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://wikipedia.api.trendsapi.ai/mcp認証が必要

ツール

詳細

Wikipedia ページビューのトレンド API

Trends API による Wikipedia 記事の注目度です。閲覧履歴、増加率、リアルタイムのトレンドページを 0〜100 のスコアで確認できます。

License: MIT PyPI Python

キーの取得先:trendsapi.ai/#get-key。HTTP コントラクトと全ソースについては、trendsapi-ai/trendsapiをご覧ください。

認証

pip install trendsapi-wikipedia
export TRENDSAPI_KEY=your_key

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

from trendsapi_wikipedia import TrendsAPI

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

キーワード用ヘルパーのデフォルトは source: "wikipedia" です。同じクライアントでほかのプラットフォームを利用するには、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 は小文字(wikipedia)で指定します。type は正確な値(Wikipedia Trending)を指定します。両方を混在させると 400 エラーになります。

from trendsapi_wikipedia import TrendsAPI

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

series = client.get_time_series("large language model")
print(series[-1].date, series[-1].value)

growth = client.get_growth("large language model", 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("large language model")

各データポイント:

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

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

get_growth

g = client.get_growth("large language model", 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[順位, ラベル] の行

Python:hot.data。JS:hot.data。offset= と category= は任意です(Amazon Best Sellers by Category、Top Websites のみ)。

非同期

import asyncio
from trendsapi_wikipedia import AsyncTrendsAPI

async def main():
    c = AsyncTrendsAPI()
    return await asyncio.gather(
        c.get_time_series("large language model"),
        c.get_time_series("large language model", source="google search"),
    )

asyncio.run(main())

200 のレスポンス 1 件につき、課金対象のリクエストは 1 回です。

Pandas

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

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

呼び出し(curl)

フィールド値
エンドポイントPOST https://api.trendsapi.ai/api
認証Authorization: Bearer $TRENDSAPI_KEY
履歴get_time_series または get_growth と source: wikipedia
キーワード記事名またはトピック(例:large language model)
ライブの typeWikipedia Trending
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":"wikipedia","keyword":"large language model"}'

ソースに関する注意事項

  • タイトルは厳密に一致させる必要があります。Java と Java (programming language) は別の系列です。
  • get_top_trends では source: wikipedia を指定しないでください。type: Wikipedia Trending を使用してください。

エラー

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

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

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

ライセンス

MIT。LICENSEをご覧ください。

コメント

MCP は初めてですか?

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

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