Reddit Search
Search Reddit posts globally or within a subreddit.
POST
/v1/reddit/search Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| query | body | string | Yes | Search query. |
| after | body | string | No | Cursor returned by the previous response. |
| before | body | string | No | Cursor returned by the previous response. |
| limit | body | integer | No | Maximum number of items to return. |
| sort | body | string | No | Sort order. Global search supports relevance, new, top, and comment_count; subreddit search also supports hot and comments. |
| subreddit | body | string | No | Subreddit name, r/name, or subreddit URL. |
| timeframe | body | string | No | Timeframe for results where supported. |
Response Structure
Async kickoff response
Polled run result response
Sync response
Declared output schema
Code Examples
Async + polling
RUN=$(curl -s -X POST "https://api.browsable.app/v1/reddit/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query":"machine learning","after":"sample","before":"sample","limit":25,"sort":"relevance","subreddit":"programming","timeframe":"hour"}')
RUN_ID=$(echo "$RUN" | jq -r '.run_id')
while true; do
RESULT=$(curl -s -H "Authorization: Bearer YOUR_API_KEY" "https://api.browsable.app/v1/runs/$RUN_ID")
STATUS=$(echo "$RESULT" | jq -r '.run_status')
if [ "$STATUS" = "succeeded" ] || [ "$STATUS" = "failed" ]; then
echo "$RESULT"
break
fi
sleep 2
doneSync
curl -X POST "https://api.browsable.app/v1/reddit/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query":"machine learning","after":"sample","before":"sample","limit":25,"sort":"relevance","subreddit":"programming","timeframe":"hour","_run":{"async":false}}'