subredditstring必須
Subreddit name without the r/ prefix (e.g. 'Fitness').
https://api.sandbase.ai/v1/api/reddit/subreddit-searchSearch posts within a single subreddit by query, sort, and timeframe.
出力はここに表示されます
入力を完了してから[実行]をクリックしてください。
Returns Reddit posts from one subreddit that match a search query. It needs a subreddit name without the r/ prefix, and it accepts an optional query, sort and timeframe.
score or numComments to see which threads got the most attention.new.curl -X POST "https://api.sandbase.ai/v1/api/reddit/subreddit-search" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "push ups", "subreddit": "Fitness"}'
The result is returned in outputs[0].data.
| Name | Type | Required | Description |
|---|---|---|---|
subreddit | string | Yes | Subreddit name without the r/ prefix (e.g. 'Fitness'). |
cursor | string | No | Optional pagination token from a previous response. Include nextCursor in requireFields on the first request to make sure a source that supports pagination serves it. |
query | string | No | Optional search query to match posts (e.g. 'push ups'). |
requireFields | array | No | Optional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example nextCursor or selftext, and it is served only by a source that ret |
sort | string | No | Optional sort order: relevance, hot, top, new, comments. |
timeframe | string | No | Optional time filter: all, year, month, week, day, hour. |
Real response for the request above, trimmed: lists keep their first item and long strings are cut.
{
"data": {
"nextCursor": "cur_vSRO4dkJp_Wni4NIHlJvKQ",
"posts": [
{
"author": "Yea_Red",
"authorId": "j6hq9",
"createdUtc": 1428859519,
"id": "32cksu",
"nsfw": false,
"numComments": 528,
"permalink": "/r/Fitness/comments/32cksu/how_much_will_pushups_help_my_chest/",
"score": 2003,
"selftext": "I try to do 100 a day. Is this doing anything for me, or should I just focus on …",
"subreddit": "Fitness",
"title": "How much will push-ups help my chest?",
"url": "https://www.reddit.com/r/Fitness/comments/32cksu/how_much_will_pushups_help_my_c…"
}
]
},
"found": true
}
| Field | Meaning |
|---|---|
data.posts[].title | Title of the post. |
data.posts[].selftext | Body text of the post. Long text may be cut, and link posts may have none. |
data.posts[].score | Score of the post. |
data.posts[].numComments | Number of comments on the post. |
data.posts[].author / data.posts[].authorId | Username and ID of the post author. |
data.posts[].createdUtc | Creation time of the post as a Unix timestamp in seconds (UTC). |
data.posts[].id | Short ID of the post, such as 32cksu. |
data.posts[].permalink / data.posts[].url | Path and full URL of the post on Reddit. |
data.posts[].nsfw | true if the post is marked NSFW. |
data.nextCursor | Token to pass as cursor to get the next page of results. |
For a Python request example that keeps the search and comment parameters separate, follow the community-research tutorial.
Fitness.nextCursor to requireFields on the first request. Then send the returned data.nextCursor as cursor on the next call.selftext, isArchived or isLocked to requireFields if you need those fields on every post.Billed at the actual cost of each call, about $0.00035 for the request above. Failed calls are not charged.
開発を始める
統一認証と使用状況の追跡を備えたプラットフォームAPIエンドポイントです。
curl -X POST "https://api.sandbase.ai/v1/api/reddit/subreddit-search" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "push ups",
"subreddit": "Fitness"
}'SandBaseのAPIキーをサーバー環境に設定してください。リクエストはBearer認証を使用します。
export SANDBASE_API_KEY="YOUR_API_KEY"キーはサーバー側で管理してください。ブラウザコードに公開しないでください。
subredditstring必須Subreddit name without the r/ prefix (e.g. 'Fitness').
sortstringOptional sort order: relevance, hot, top, new, comments.
指定可能な値: relevance, hot, top, new, comments
querystringOptional search query to match posts (e.g. 'push ups').
cursorstringOptional pagination token from a previous response. Include `nextCursor` in requireFields on the first request to make sure a source that supports pagination serves it.
timeframestringOptional time filter: all, year, month, week, day, hour.
指定可能な値: all, year, month, week, day, hour
requireFieldsarrayOptional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example `nextCursor` or `selftext`, and it is served only by a source that returns every one of them. Fields you do not name are still returned whenever the serving source has them. This can raise your price: when the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. Name `nextCursor` only if you will fetch more than the first page: when you leave it out, a cheaper source that cannot paginate may serve the request, and its nextCursor is null, so there is no next page to ask for. A named field can still be absent on a post that genuinely lacks it. Naming a combination that no single source returns together is refused as invalid input, with no charge. On a paginated walk it applies to the first page only; later pages stay with the source that page chose, at the price it was quoted.
このAPIの保存済みサンプルレスポンスです。表示時にライブリクエストは行われません。
保存済みレスポンスはまだ公開されていません。PlaygroundでAPIを実行し、レスポンスを確認してください。
さらに探索
| API | 価格 | レスポンス |
|---|---|---|
Reddit Subreddit Searchこの API Reddit | 1回あたり $0.00035 から | JSON |
Reddit | $0.001 / 回 | JSON |
Reddit | $0.001 / 回 | JSON |
Reddit | $0.001 / 回 | JSON |
Reddit | $0.001 / 回 | JSON |
Reddit | $0.001 / 回 | JSON |
質問
Authorization ヘッダー(Bearer)に SandBase API key を指定し、パラメータを JSON ボディで送信して https://api.sandbase.ai/v1/api/reddit/subreddit-search に POST リクエストを送ります。このページの Playground で、コードを書かずに試すこともできます。
1回あたり $0.00035 から、SandBase 残高から課金されます。課金対象はご利用分のみで、サブスクリプションはありません。
必須: subreddit (string)。 任意: sort(relevance, hot, top, new, comments のいずれか), query (string), cursor (string), timeframe(all, year, month, week, day, hour のいずれか) と requireFields (array)。 このページの Parameters テーブルと Playground に、すべてのフィールドが一覧表示されています。
同じ HTTP リクエスト内で返される JSON レスポンスです(同期)。 このページの README にサンプルレスポンスがあります。
いいえ。Reddit Subreddit Search は SandBase 経由で動作するため、SandBase の API key 1つでこのエンドポイントと、カタログ内の他のすべての API とモデルを利用できます。Reddit の API アクセスを別途申請する必要はありません。
subreddit には r/ を付けずにコミュニティ名を渡し、query に検索語を入れてください。この endpoint は sort と timeframe を受け付けます。公式 Reddit API のパラメータ名ではなく、記載された値を使用してください。Keyword Search と app Dynamic Search の endpoint では、リクエストフィールドが異なります。
ページネーションが必要な場合は、最初の呼び出しで requireFields に nextCursor を要求し、その引用価格を確認してください。フィールド指定によって、より高価な source を選べる場合があります。次ページには、返された data.nextCursor を完全な形で cursor として渡してください。後続ページは最初のページで選択した source のままです。この指定がないと、より安価な source では継続が返らない場合があります。要求したフィールドは、実際にその値を持たない投稿では欠落していてもかまいません。ドキュメント例の短縮された cursor は再利用しないでください。
いいえ。参照では selftext が省略されたり短縮されたりする場合があり、検索結果は完全な議論アーカイブではなくサンプルです。返信が必要な場合は、選択した投稿を開き、URL を使って Post Comments endpoint を利用してください。タイトル、スニペット、スコアを検証済みの製品フィードバックとみなさないでください。