mcpField
N
News Volume API

News Volume API

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

News Volume API について

News Volume API は、トピックに関するニュース記事の言及量を時系列、成長率、ライブデータで提供します。開発者やメディア分析担当者は、Python、JavaScript/TypeScript クライアントまたは HTTP から利用できます。

主な機能

  1. 01ニュース言及量の時系列
  2. 02期間指定による成長率
  3. 03ページネーション付きライブトレンド
  4. 04Python と JavaScript/TypeScript クライアント
  5. 05Pandas でのデータ処理

活用シーン

  1. 01トピックに関する記事の言及量の監視
  2. 02リアルタイムのニューストレンド確認
  3. 03期間別の言及量成長の比較

設定

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

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

ツール

詳細

ニュースの言及量 API

Trends API によるニュースの言及量です。ニュースサイトをスクレイピングせずにメディアをモニタリングできます。

License: MIT PyPI Python npm

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

認証

pip install news-trends-api
export TRENDSAPI_KEY=your_key

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

from news_trends_api import TrendsAPI

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

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

from news_trends_api import TrendsAPI

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

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

growth = client.get_growth("federal reserve", 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("federal reserve")

各データポイント:

フィールド常に含まれる意味
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("federal reserve", 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 news_trends_api import AsyncTrendsAPI

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

asyncio.run(main())

HTTP 200 の応答 1 件につき、課金対象のリクエストは 1 件です。

Pandas

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

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

JavaScript / TypeScript

npm install news-trends-api

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

メソッド
メソッド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 "news-trends-api";

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

const growth = await client.getGrowth("federal reserve", {
  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: news volume
キーワード任意の語句(例:federal reserve)
ライブ typeGoogle News Top News
curl -sS -X POST https://api.trendsapi.ai/api \
  -H "Authorization: Bearer $TRENDSAPI_KEY" \
  -H "Content-Type: application/json" \
  --max-time 60 \
  -d '{"mode":"get_time_series","source":"news volume","keyword":"federal reserve"}'

ソースに関する注意

  • このソースは応答が遅い場合があります。HTTP 504 の HTML 応答は課金対象ではありません。再試行してください。
  • source: news sentiment はトーンを示すもので、言及数ではありません。

エラー

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

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

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

ライセンス

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

コメント

MCP は初めてですか?

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

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