1. Retrieve High-Signal Posts & Top Comment Trees
Search relevant subreddits for a technical query, then fetch the top-ranked comment hierarchy for the highest-scoring threads.
- Step 1 — Discovery: Query GET /v1/posts/search?query=...&sort=relevance&time_filter=year&limit=10 to find canonical threads.
- Step 2 — Context Expansion: Fetch GET /v1/posts/comments?post_id=...&sort=top&limit=50 to capture verified community answers and counter-arguments.
- Step 3 — Score Weighting: Include score, subreddit, created_at, and permalink in every chunk metadata payload for verifiable LLM citations.
| Data Layer | Items Ingested | Data Cost | Median Tool Latency |
|---|---|---|---|
| ForumData API | 105,000 items | $10.50 ($6.04 Pro) | ~220ms synchronous |
| Official Reddit OAuth | 6,000+ calls | Restricted for commercial AI/LLM | 100 QPM throttled |
| Apify Reddit Actors | 105,000 items | $157.50+ | 35–60s cold container |
End-to-end Reddit RAG context builder
Fetch top threads + comments and format structured markdown chunks with real source permalinks.
curl "https://api.forumdataapi.com/v1/subreddit/posts?subreddit=saas&sort=hot&limit=5" \
-H "x-api-key: rd_live_your_api_key"import os, requests
API_KEY = os.environ["REDDIT_API_KEY"]
HEADERS = {"x-api-key": API_KEY}
def build_reddit_rag_chunks(subreddit: str = "saas") -> list[dict]:
posts = requests.get(
"https://api.forumdataapi.com/v1/subreddit/posts",
params={"subreddit": subreddit, "sort": "hot", "limit": 5},
headers=HEADERS,
timeout=15,
).json()["data"]["items"]
chunks = []
for post in posts:
comments = requests.get(
"https://api.forumdataapi.com/v1/posts/comments",
params={"post_id": post["id"], "sort": "top", "limit": 20},
headers=HEADERS,
timeout=15,
).json()["data"]["items"]
top_replies = [f"- ({c['score']} pts) u/{c['author']}: {c['body']}" for c in comments if c["score"] >= 5][:10]
chunks.append({
"id": post["post_id"],
"url": post["permalink"],
"subreddit": post["subreddit_name_prefixed"],
"text": f"# {post['title']}\n\n{post['selftext'][:600]}\n\n## Top Community Replies\n" + "\n".join(top_replies),
})
return chunksconst headers = { "x-api-key": process.env.REDDIT_API_KEY };
const searchRes = await fetch(
"https://api.forumdataapi.com/v1/subreddit/posts?subreddit=saas&sort=hot&limit=5",
{ headers },
);
const { data } = await searchRes.json();
console.log(`Fetched ${data.items.length} canonical Reddit threads`);{
"id": "t3_1u0z4vz",
"url": "https://reddit.com/r/SaaS/comments/1u0z4vz/new_rule_banning_a_saas_product_category_no/",
"subreddit": "r/SaaS",
"score": 570,
"num_comments": 326,
"top_reply_sample": "- (86 pts) u/reallehnert: Great News!"
}Interactive Engineering Workbench · GET /v1/posts/search
Verify real-time latency, pagination math & JSON schema
Frequently Asked Questions
- Can Claude Desktop or Cursor call ForumData API directly via MCP?
- Yes! Visit https://forumdataapi.com/mcp for a copy-paste Model Context Protocol server configuration that exposes Reddit search and comment extraction to Claude and Cursor.