RedditSubreddit infoAPI
APIの稼働状況
- 24時間の稼働状況
- 正常
- 良好/正常
- 利用可能
過去24時間
過去30日間
1つのサブレディットのプロフィールを単一のオブジェクトとして取得します。subredditは必須で、コミュニティ名(pythonまたはr/python)またはコミュニティのリンクを、1回の呼び出しにつき1つ指定します。オブジェクトには、community(r/を除いた名前)、community_id(t5_で始まります)、url、title、description、member_count(リクエストによっては返らないことがあります)、weekly_visitor_countとweekly_contribution_count(コミュニティページに表示される週間の訪問者数と投稿数)、created_at、community_type(public、restricted、private)、icon_url、banner_urlが含まれます。存在しない、非公開、または禁止されたコミュニティを指定すると空の結果が返ります。ルールとメニューリンクはsubreddit_rulesにあります。
POST https://api.everyinfra.com/api/v1/socialを送信し、platformにreddit、actionにsubreddit_infoを指定します。 料金は1,000リクエストあたり$0.79(1回あたり$0.000792)です。失敗した呼び出しと空の結果には課金されません。 同期処理です。時間のかかるジョブでは、ボディに"mode": "async"を追加し、job_idを取得してポーリングしてください。
AIプロンプト
#EveryInfraのReddit Subreddit infoエンドポイント(reddit/subreddit_info)を使ったデータ収集スクリプトの作成を手伝ってください。
エンドポイントの仕組み:
- リクエスト:ヘッダーにAuthorization: Bearer <API key>を指定して、https://api.everyinfra.com/api/v1/socialにPOSTします。APIキーは環境変数EVERYINFRA_API_KEYから読み込み、ハードコードしないでください。
- リクエストボディでplatformにreddit、actionにsubreddit_infoを指定し、パラメータはparamsの中に入れます。
- 必須パラメータ:
- subreddit: The community to look up: a name (python or r/python) or a community link. One community per call.
- 1つのオブジェクトを返します。主なフィールド: community、community_id(Reddit's ID for the community, starting…)、url、title、description、member_count(How many members the community has (sub…)、weekly_visitor_count(Weekly visitors to the community as Red…)、weekly_contribution_count(Weekly contributions to the community,…)、created_at、community_type(Type of the community: public, restrict…)、icon_url(Image URL of the icon: the community ic…)、banner_url(Image URL of the banner on the communit…).
- リクエストボディの例:
{
"platform": "reddit",
"action": "subreddit_info",
"params": {
"subreddit": "python"
}
}
- 料金:1,000リクエストあたり$0.79。失敗時および結果が空の場合は課金されません。
- 対象が数十〜数百件ある場合は、ボディに"mode": "async"を追加します。すぐにjob_idが返されるので、GET https://api.everyinfra.com/api/v1/jobs/{job_id}をポーリングして結果を取得します。
- 422の場合は、エラーに含まれる推奨パラメータ名と指定可能な値を使ってリクエストを修正します。429または503の場合は、Retry-Afterの指定に従って待ってから再試行します。
コードを書く前に、必要な対象とその件数、必要なフィールド、希望する出力形式を私に質問してください。そのうえで、計画と概算費用を私に確認してください。リクエストパラメータ
#| 名前 | 場所 | 型 | 必須 | デフォルト | 説明 |
|---|---|---|---|---|---|
Authorization | header | string | はい | - | Bearerの後にAPIキーを続けます。APIキーはコンソールで作成してください。URLやコードリポジトリには絶対に含めないでください。 |
platform | body | string | はい | reddit | プラットフォームの識別子です。値は固定です。 |
action | body | string | はい | subreddit_info | 機能の識別子です。値は固定です。 |
subreddit | body.params | string | はい | - | The community to look up: a name (python or r/python) or a community link. One community per call. |
コードサンプル
#curl -X POST 'https://api.everyinfra.com/api/v1/social' \
-H "Authorization: Bearer $EVERYINFRA_API_KEY" \
-H 'Content-Type: application/json' \
--data-raw '{
"platform": "reddit",
"action": "subreddit_info",
"params": {
"subreddit": "python"
}
}'OpenAPI定義(JSON)サンプルは環境変数EVERYINFRA_API_KEYからAPIキーを読み込みます。コピーしたコードにAPIキーが含まれることはありません。
レスポンス例
#{ "id": "req_…", "platform": "reddit", "action": "subreddit_info", "results": { "community": …, "community_id": …, "url": …, "title": …, "description": …, "member_count": …, "weekly_visitor_count": …, "weekly_contribution_count": …, "created_at": …, "community_type": …, "icon_url": …, "banner_url": …, "platform": … }, "billing": { "charged": …, "charged_usd": …, "balance_after_usd": …, … }, "quota": { … }}
レスポンスフィールド
#業務データはresultsに含まれます。この表はレコードに含まれうるフィールドの一覧です。プラットフォームに表示されない値を作り出すことはありません。
| フィールド | 意味 |
|---|---|
community | プラットフォーム上の意味のまま |
community_id | Reddit's ID for the community, starting with t5_ (subreddit_info, subreddit_rules, search_suggest, user_subreddits, explore, topic_subreddits). |
url | プラットフォーム上のレコードへのリンクです。 |
title | タイトルです。プラットフォームにタイトルがない場合(テキストのみの投稿など)はnullになります。 |
description | 概要または説明文で、通常はtextより短くなります。 |
member_count | How many members the community has (subreddit_info, user_subreddits). A few requests come back without it. |
weekly_visitor_count | Weekly visitors to the community as Reddit shows it (subreddit_info, explore, topic_subreddits). In search_suggest it is the rounded figure from the dropdown, so 93K is recorded as 93000, and not every row has it. |
weekly_contribution_count | Weekly contributions to the community, as shown on its page (subreddit_info). |
created_at | 作成日時です。形式はposted_atと同じです。 |
community_type | Type of the community: public, restricted or private (subreddit_info). |
icon_url | Image URL of the icon: the community icon (subreddit_info, subreddit_rules, search_suggest, user_subreddits, explore, topic_subreddits) or the achievement icon (user_trophies). |
banner_url | Image URL of the banner on the community page (subreddit_info, subreddit_rules) or on the user's profile (profile). |
platform | 取得元プラットフォームの識別子で、リクエストのplatformと同じです(例:xiaohongshu、tiktok)。 |
エラーと課金
#- 401
- キーが未指定か無効です。
- 402
- 残高が不足しています。先にチャージしてください。
- 422
- パラメータ名または値が無効です。エラーに含まれる候補を参考に修正してください。課金はされません。
- 429
- 1分あたりのリクエスト上限に達しました。Retry-Afterの指定に従って待ってから再試行してください。
- 503
- 処理を完了できませんでした。保留中の請求額は残高に戻されます。結果が不明な場合は、再試行する前に確認してください。
- 200(空)
- データがありません。課金はされません。