mcpField
R
Reddit Trends API

Reddit Trends API

リモート
trendsapi.aiソーシャルメディア010 週間前に更新
リポジトリ公式サイト

Reddit Trends API について

Reddit Trends APIは、Redditの議論履歴や成長率、最新の人気投稿を取得するPythonクライアントです。Trends APIでサブレディットやトピックへの注目度を分析する開発者向けです。

主な機能

  1. 01議論量の時系列データ
  2. 02期間別の成長率
  3. 03最新の人気投稿フィード
  4. 04同期・非同期クライアント

活用シーン

  1. 01サブレディットの注目度追跡
  2. 02トピックの期間別成長比較
  3. 03現在のReddit人気投稿の取得

設定

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

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

ツール

詳細

Reddit の注目度 API

Trends API による Reddit の注目度トレンド。サブレディットの履歴、成長率、リアルタイムの人気投稿を確認できます。PRAW ではありません。

License: MIT PyPI Python

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

認証

pip install trendsapi-reddit
export TRENDSAPI_KEY=your_key

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

from trendsapi_reddit import TrendsAPI

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

キーワードヘルパーのデフォルトは source: "reddit" です。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 は小文字(reddit)です。type は完全一致(Reddit Hot Posts)です。混在させると 400 エラーになります。

from trendsapi_reddit import TrendsAPI

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

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

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

各ポイント:

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

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

asyncio.run(main())

200 のレスポンスごとに、課金対象のリクエストが 1 回発生します。

Pandas

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

df = pd.DataFrame(asdict(p) for p in TrendsAPI().get_time_series("wallstreetbets"))
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: reddit
キーワードサブレディットまたはトピック。r/ の接頭辞は付けません。例:wallstreetbets
ライブの typeReddit Hot Posts、Reddit World News
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":"reddit","keyword":"wallstreetbets"}'

ソースに関する注意事項

  • source は常に reddit です。コミュニティ名は keyword に指定します。
  • value は登録者数ではありません。
  • 投稿、投票、コメントのストリーミングはできません。

エラー

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

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

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

ライセンス

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

コメント

MCP は初めてですか?

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

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