Skip to content

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Reddit Scraper API by ScrapeBadger

Get API key Docs MCP server Pricing

Reddit Scraper API

Get public Reddit data as JSON without registering an OAuth app or managing API keys from Reddit. The Reddit Scraper API returns search results for posts, subreddits and users, full posts with their comment trees, subreddit feeds, rules and wikis, user profiles and history, trending posts and posts by domain. This repo has a runnable Python, Node.js and cURL example for the main endpoints and the real response each one returned.

What does a Reddit scraper do?

A Reddit scraper collects public posts, comments, subreddit and user data from Reddit and returns it as structured data. Product teams use it to find what users complain about, marketers to track brand mentions, and researchers to build datasets. With this API you send a keyword, subreddit, post ID or username and get JSON back: titles, scores, comment trees, authors and timestamps.

Contents

Quick start

  1. Create a free ScrapeBadger account. You get 1,000 free credits, no card needed.

  2. Copy your API key from the dashboard and export it:

    export SCRAPEBADGER_API_KEY="your_api_key"
  3. Make your first request: search Reddit posts.

cURL

curl -sS --max-time 120 -G "https://scrapebadger.com/v1/reddit/search/posts" \
  -H "X-API-Key: $SCRAPEBADGER_API_KEY" \
  --data-urlencode 'q=web scraping' \
  --data-urlencode 'limit=10'

Python (pip install requests)

import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

response = requests.get(
    "https://scrapebadger.com/v1/reddit/search/posts",
    headers={"X-API-Key": API_KEY},
    params={
        "q": "web scraping",
        "limit": 10,
    },
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js (18+, no dependencies)

const params = new URLSearchParams({
  q: 'web scraping',
  limit: '10',
});

const response = await fetch(`https://scrapebadger.com/v1/reddit/search/posts?${params}`, {
  headers: { 'X-API-Key': process.env.SCRAPEBADGER_API_KEY },
  signal: AbortSignal.timeout(120000),
});
if (!response.ok) {
  throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(JSON.stringify(await response.json(), null, 2));

Every endpoint below has the same three versions in examples/, and the real response it returned is in output-samples/.

Endpoints

Base URL: https://scrapebadger.com. Authenticate with the X-API-Key header. Credits are charged only for successful requests.

Endpoint What it returns Credits per request Docs
GET /v1/reddit/search/posts Search Reddit posts 8 Docs
GET /v1/reddit/search/subreddits Search subreddits 8 Docs
GET /v1/reddit/search/users Search users 8 Docs
GET /v1/reddit/posts/trending Get trending posts 3 Docs
GET /v1/reddit/posts/{post_id} Get post detail 8 Docs
GET /v1/reddit/posts/{post_id}/comments Get post comments 15 Docs
GET /v1/reddit/posts/{post_id}/duplicates Get cross-posts 15 Docs
GET /v1/reddit/subreddits/{subreddit} Get subreddit info 5 Docs
GET /v1/reddit/subreddits/{subreddit}/posts Get subreddit posts 8 Docs
GET /v1/reddit/subreddits/{subreddit}/rules Get subreddit rules 3 Docs
GET /v1/reddit/subreddits/{subreddit}/wiki List wiki pages 3 Docs
GET /v1/reddit/subreddits/{subreddit}/wiki/{page} Get wiki page content 15 Docs
GET /v1/reddit/subreddits/popular Popular subreddits 3 Docs
GET /v1/reddit/subreddits/new New subreddits 3 Docs
GET /v1/reddit/users/{username} Get user profile 5 Docs
GET /v1/reddit/users/{username}/posts Get user's posts 8 Docs
GET /v1/reddit/users/{username}/comments Get user's comments 8 Docs
GET /v1/reddit/users/{username}/moderated Get user's moderated subreddits 15 Docs
GET /v1/reddit/users/{username}/trophies Get user's trophies 3 Docs
GET /v1/reddit/domains/{domain}/posts Get posts by domain 8 Docs

Common parameters

Parameter Description Default
limit Items per page on list endpoints (search, feeds, comments, user history). 25
after Cursor from the previous page's response, to get the next page.
sort Sort order. Search uses relevance, hot, top, new or comments; feeds use hot, new, top, rising.
t Time window for top sorts, one of hour, day, week, month, year, all. all

Examples by endpoint

Each example prints the JSON response. The Python versions are below; Node.js and cURL versions are linked under each one.

Search Reddit posts

Search Reddit's current web UI globally or within one or more subreddits.

GET /v1/reddit/search/posts · Credits: 8 · Docs

Parameter Required Type Default Description
q Yes string Search query (Reddit search syntax), at most 256 UTF-8 bytes
subreddit string Subreddit name without r/, e.g. python
sort string relevance Sort: relevance, hot, top, new, comments
t string all Time: hour, day, week, month, year, all
limit integer 25 Items per page on list endpoints (search, feeds, comments, user history).
after string Cursor from the previous page's response, to get the next page.
import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

response = requests.get(
    "https://scrapebadger.com/v1/reddit/search/posts",
    headers={"X-API-Key": API_KEY},
    params={
        "q": "web scraping",
        "limit": 10,
    },
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js · cURL · Output sample (56 KB)

Get a post

Get detailed information about a Reddit post.

GET /v1/reddit/posts/{post_id} · Credits: 8 · Docs

Parameter Required Type Default Description
post_id Yes string Reddit post ID, the part after /comments/ in a post URL, e.g. 1obwkbb
import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

post_id = "1obwkbb"

response = requests.get(
    f"https://scrapebadger.com/v1/reddit/posts/{post_id}",
    headers={"X-API-Key": API_KEY},
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js · cURL · Output sample (3 KB)

Get a post's comments

Get comment tree for a Reddit post.

GET /v1/reddit/posts/{post_id}/comments · Credits: 15 · Docs

Parameter Required Type Default Description
post_id Yes string Reddit post ID, the part after /comments/ in a post URL, e.g. 1obwkbb
sort string confidence Sort: confidence, top, new, controversial, old, qa
limit integer 25 Items per page on list endpoints (search, feeds, comments, user history).
depth integer
import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

post_id = "1obwkbb"

response = requests.get(
    f"https://scrapebadger.com/v1/reddit/posts/{post_id}/comments",
    headers={"X-API-Key": API_KEY},
    params={
        "limit": 10,
    },
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js · cURL · Output sample (19 KB)

Get subreddit info

Get detailed information about a subreddit.

GET /v1/reddit/subreddits/{subreddit} · Credits: 5 · Docs

Parameter Required Type Default Description
subreddit Yes string Subreddit name without r/, e.g. python
import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

subreddit = "python"

response = requests.get(
    f"https://scrapebadger.com/v1/reddit/subreddits/{subreddit}",
    headers={"X-API-Key": API_KEY},
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js · cURL · Output sample (16 KB)

Get subreddit posts

Get posts from a subreddit with sorting options.

GET /v1/reddit/subreddits/{subreddit}/posts · Credits: 8 · Docs

Parameter Required Type Default Description
subreddit Yes string Subreddit name without r/, e.g. python
sort string hot Sort: hot, new, top, rising, controversial
t string all Time filter
limit integer 25 Items per page on list endpoints (search, feeds, comments, user history).
after string Cursor from the previous page's response, to get the next page.
import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

subreddit = "python"

response = requests.get(
    f"https://scrapebadger.com/v1/reddit/subreddits/{subreddit}/posts",
    headers={"X-API-Key": API_KEY},
    params={
        "sort": "hot",
        "limit": 10,
    },
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js · cURL · Output sample (52 KB)

Get subreddit rules

Get the rules of a subreddit.

GET /v1/reddit/subreddits/{subreddit}/rules · Credits: 3 · Docs

Parameter Required Type Default Description
subreddit Yes string Subreddit name without r/, e.g. python
import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

subreddit = "python"

response = requests.get(
    f"https://scrapebadger.com/v1/reddit/subreddits/{subreddit}/rules",
    headers={"X-API-Key": API_KEY},
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js · cURL · Output sample (9 KB)

Get trending posts

Get trending posts from Reddit's front page.

GET /v1/reddit/posts/trending · Credits: 3 · Docs

Parameter Required Type Default Description
sort string hot Sort: hot, new, top, rising, controversial, best
t string day Time filter
limit integer 25 Items per page on list endpoints (search, feeds, comments, user history).
after string Cursor from the previous page's response, to get the next page.
import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

response = requests.get(
    "https://scrapebadger.com/v1/reddit/posts/trending",
    headers={"X-API-Key": API_KEY},
    params={
        "limit": 10,
    },
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js · cURL · Output sample (35 KB)

Search subreddits

Search communities using Reddit's current web UI ranking and pagination.

GET /v1/reddit/search/subreddits · Credits: 8 · Docs

Parameter Required Type Default Description
q Yes string Search query, at most 256 UTF-8 bytes
limit integer 25 Items per page on list endpoints (search, feeds, comments, user history).
after string Cursor from the previous page's response, to get the next page.
import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

response = requests.get(
    "https://scrapebadger.com/v1/reddit/search/subreddits",
    headers={"X-API-Key": API_KEY},
    params={
        "q": "programming",
        "limit": 10,
    },
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js · cURL · Output sample (74 KB)

Get a user profile

Get a Reddit user's profile.

GET /v1/reddit/users/{username} · Credits: 5 · Docs

Parameter Required Type Default Description
username Yes string Reddit username without u/, e.g. spez
import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

username = "spez"

response = requests.get(
    f"https://scrapebadger.com/v1/reddit/users/{username}",
    headers={"X-API-Key": API_KEY},
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js · cURL · Output sample (1 KB)

Get a user's posts

Get posts submitted by a Reddit user.

GET /v1/reddit/users/{username}/posts · Credits: 8 · Docs

Parameter Required Type Default Description
username Yes string Reddit username without u/, e.g. spez
sort string new Sort order. Search uses relevance, hot, top, new or comments; feeds use hot, new, top, rising.
t string all Time window for top sorts, one of hour, day, week, month, year, all.
limit integer 25 Items per page on list endpoints (search, feeds, comments, user history).
after string Cursor from the previous page's response, to get the next page.
import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

username = "spez"

response = requests.get(
    f"https://scrapebadger.com/v1/reddit/users/{username}/posts",
    headers={"X-API-Key": API_KEY},
    params={
        "limit": 10,
    },
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js · cURL · Output sample (76 KB)

Get posts linking to a domain

Get Reddit posts linking to a specific domain.

GET /v1/reddit/domains/{domain}/posts · Credits: 8 · Docs

Parameter Required Type Default Description
domain Yes string A website domain, e.g. github.com, to list posts that link to it
sort string hot Sort order. Search uses relevance, hot, top, new or comments; feeds use hot, new, top, rising.
t string all Time window for top sorts, one of hour, day, week, month, year, all.
limit integer 25 Items per page on list endpoints (search, feeds, comments, user history).
after string Cursor from the previous page's response, to get the next page.
import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

domain = "github.com"

response = requests.get(
    f"https://scrapebadger.com/v1/reddit/domains/{domain}/posts",
    headers={"X-API-Key": API_KEY},
    params={
        "limit": 10,
    },
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js · cURL · Output sample (64 KB)

List popular subreddits

Get popular subreddits by subscriber count.

GET /v1/reddit/subreddits/popular · Credits: 3 · Docs

Parameter Required Type Default Description
limit integer 25 Items per page on list endpoints (search, feeds, comments, user history).
after string Cursor from the previous page's response, to get the next page.
import json
import os

import requests

API_KEY = os.environ["SCRAPEBADGER_API_KEY"]

response = requests.get(
    "https://scrapebadger.com/v1/reddit/subreddits/popular",
    headers={"X-API-Key": API_KEY},
    params={
        "limit": 10,
    },
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))

Node.js · cURL · Output sample (86 KB)

Example output

A real response from GET /v1/reddit/search/posts, trimmed to the first items of each list. The full response is in output-samples/search-posts.json.

{
  "posts": [
    {
      "id": "1x2h4zj",
      "fullname": "t3_1x2h4zj",
      "title": "Why is it so fussed over web scraping now?",
      "author": "Consistent_Tutor_597",
      "author_fullname": "t2_wbsl9fakr",
      "selftext": "Guys. Why is claude acting like a wanker lately. I just wanted it to download 20-30 reports from the internet to compare numbers and sometimes if he gets either a cloudflare check or reads some silly policy on robots.txt…",
      "selftext_html": "<!-- SC_OFF --><div class=\"md\"><p>Guys. Why is claude acting like a wanker lately. I just wanted it to download 20-30 reports from the internet to compare numbers and sometimes if he gets either a cloudflare check or rea…",
      "search_snippet": null,
      "url": "https://www.reddit.com/r/ClaudeCode/comments/1x2h4zj/why_is_it_so_fussed_over_web_scraping_now/",
      "permalink": "/r/ClaudeCode/comments/1x2h4zj/why_is_it_so_fussed_over_web_scraping_now/",
      "domain": "self.ClaudeCode",
      "subreddit": "ClaudeCode",
      "subreddit_id": "t5_dp6k3k",
      "subreddit_name_prefixed": "r/ClaudeCode",
      "subreddit_type": "public",
      "subreddit_subscribers": 519390,
      "score": 155,
      "ups": 155,
      "downs": 0,
      "upvote_ratio": 0.84,
      "num_comments": 143,
      "num_crossposts": 0,
      "total_awards_received": 0,
      "view_count": null,
      "gilded": 0,
      "created_utc": 1791643753.0,
      "created_at": "2026-10-10T14:49:13+00:00",
      "edited": false,
      "is_self": true,
      "is_video": false,
      "is_gallery": false,
      "is_meta": false,
      "is_original_content": false,
      "is_robot_indexable": true,
      "is_crosspostable": true,
      "is_reddit_media_domain": false,
      "media_only": false,
      "is_nsfw": false,
      "is_spoiler": false,
      "is_stickied": false,
      "locked": false,
      "archived": false,
      "pinned": false,
      "quarantine": false,
      "hide_score": false,
      "contest_mode": false,
      "allow_live_comments": false,
      "send_replies": true,
      "distinguished": null,
      "removed_by_category": null,
      "suggested_sort": null,
      "discussion_type": null,
      "top_awarded_type": null,
      "link_flair_text": "Discussion",
      "link_flair_type": "richtext",
      "link_flair_css_class": "",
      "link_flair_template_id": "594f63e4-990b-11f0-bb51-2e3f52d6bff1",
  …

Use it with AI agents (MCP)

ScrapeBadger runs a hosted MCP server, so Claude, Cursor, ChatGPT and other agents can call the Reddit endpoints as tools, with no code.

  • Claude (claude.ai or Claude Desktop): Settings → Connectors → Add custom connector → https://mcp.scrapebadger.com/mcp, then sign in. No API key needed.
  • Cursor, VS Code, Windsurf and other clients: add this server to your MCP config:
{
  "mcpServers": {
    "scrapebadger": {
      "url": "https://mcp.scrapebadger.com/mcp?apis=reddit",
      "headers": { "Authorization": "Bearer YOUR_SCRAPEBADGER_API_KEY" }
    }
  }
}

Then ask:

Find the most upvoted r/python posts about web scraping from the past month and summarise what people recommend.

Setup guides for each client are in the MCP docs.

Use cases

Use case What you collect Endpoints
Brand monitoring Every new post that mentions your brand or product, with score and comment count Search Reddit posts
Product and market research Complaints, feature requests and comparisons from the subreddits your customers use Get subreddit posts, Get a post's comments, Search Reddit posts
Sentiment analysis Full comment trees with scores, for classification or LLM summaries Get a post, Get a post's comments
Community discovery Subreddits for a topic, their size, rules and activity Search subreddits, Get subreddit info, Get subreddit rules, List popular subreddits
Backlink and launch tracking Posts that link to your site or a competitor's, and how they did Get posts linking to a domain
AI research agents and datasets Threads and discussions on any topic, as clean JSON Search Reddit posts, Get a post's comments, Get trending posts

Pricing

  • Each endpoint's credit cost is listed in the endpoints table.
  • Only successful requests are billed. Blocked, empty and failed results cost nothing.
  • New accounts get 1,000 free credits. After that, pay as you go or pick a monthly plan. Credits on pay-as-you-go never expire.

See ScrapeBadger pricing for the price per credit on each plan.

Errors

Errors come back as JSON with a detail field (and an error code on some).

Status Meaning What to do
400 / 422 A parameter is missing or invalid Check the parameter table for the endpoint
401 Missing, invalid or expired API key Send the key in the X-API-Key header
402 Out of credits Top up or upgrade in the dashboard
403 The key can't call this API, or the request came from an IP the key doesn't allow Check the key's scopes and IP allowlist
404 The item, page or profile doesn't exist (or is no longer public) Check the ID; not billed
429 Over your account's max concurrency Wait Retry-After (1 s) and retry; run fewer calls in parallel (concurrency)
502 / 503 / 504 The target site failed or timed out on this attempt Not billed. Retry with backoff

Long calls can run asynchronously: send Prefer: respond-async and poll the returned request_id (async requests).

FAQ

Is it legal to scrape Reddit?

Collecting publicly available posts and comments is generally lawful in most jurisdictions, and this API only returns content anyone can read on Reddit without signing in. Posts and comments contain personal data, so check the rules that apply to how you store and use them (for example GDPR), and ask a lawyer if you're unsure.

Do I need a Reddit API key or OAuth app?

No. You only need a ScrapeBadger API key. There's no Reddit app to register, no OAuth flow and no Reddit rate limit to manage.

How much does it cost?

Each request costs a fixed number of credits, shown in the endpoints table, and only successful requests are billed. You get 1,000 free credits when you sign up, then pay as you go or pick a plan on the pricing page.

Can I get full comment threads?

Yes. GET /v1/reddit/posts/{post_id}/comments returns the comment tree with replies, scores and authors. Use depth to limit nesting and limit to control how many top-level comments come back.

How fast is it, and are there rate limits?

Most calls answer in 1 to 3 seconds. There's no per-minute cap: you can run as many requests in parallel as your plan's max concurrency allows, and a request over it gets 429 without being billed.

Other languages

These examples use plain HTTP. Official SDKs wrap every endpoint with types and retries:

Language Repository Install
Python scrape-badger/scrapebadger-python pip install scrapebadger
Node.js / TypeScript scrape-badger/scrapebadger-node npm install scrapebadger
Go scrape-badger/scrapebadger-go
Java scrape-badger/scrapebadger-java
C# scrape-badger/scrapebadger-csharp
PHP scrape-badger/scrapebadger-php
Ruby scrape-badger/scrapebadger-ruby
Rust scrape-badger/scrapebadger-rust
Kotlin scrape-badger/scrapebadger-kotlin
Swift scrape-badger/scrapebadger-swift
Dart scrape-badger/scrapebadger-dart
C++ scrape-badger/scrapebadger-cpp

There is also a CLI (pip install scrapebadger-cli) and an n8n node.

Related scrapers

Learn more

Disclaimer

ScrapeBadger is an independent tool and is not affiliated with, endorsed by, or sponsored by Reddit, Inc. or any of its subsidiaries or affiliates. "Reddit" is a trademark of Reddit, Inc., used here only to describe the platform this scraper works with. This repository only covers publicly available data. You are responsible for how you use the data you collect and for following the laws that apply to you.

License

MIT. The examples are free to copy into your own projects.