# Reddit Subreddit Scraper — Posts & Comments (`scrapersdelight/reddit-subreddit-scraper`) Actor

Scrape any public subreddit: posts (hot, new, top, rising, controversial) plus each post's comment tree. Title, author, selftext, score, upvote ratio, comment counts, timestamps and permalinks. No login, no Reddit API key.

- **URL**: https://apify.com/scrapersdelight/reddit-subreddit-scraper.md
- **Developed by:** [Scrapers Delight](https://apify.com/scrapersdelight) (community)
- **Categories:** Social media, AI, Marketing
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.60 / 1,000 per row returneds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Reddit Subreddit Scraper — Posts & Comments

Scrape **any public subreddit** on Reddit — the posts and, optionally, every post's comment tree —
without a login, a Reddit account, or a Reddit API key.

Give it one or more subreddit names, choose how to sort, and pull as many posts as you need. Turn on
comments to also collect the discussion under each post.

### What you get

**Posts** (`type: "post"`) — one row each:

`id`, `name` (t3\_…), `subreddit`, `subreddit_subscribers`, `title`, `author`, `selftext`, `url`,
`domain`, `permalink`, `score`, `ups`, `upvote_ratio`, `num_comments`, `num_crossposts`,
`total_awards_received`, `created_utc` / `created_iso`, `edited`, `over_18`, `spoiler`, `stickied`,
`locked`, `is_video`, `link_flair_text`, `post_hint`, `thumbnail`.

**Comments** (`type: "comment"`, when enabled) — one row per comment, including nested replies:

`id`, `name` (t1\_…), `post_id`, `parent_id`, `depth`, `author`, `body`, `score`,
`controversiality`, `created_utc` / `created_iso`, `is_submitter`, `permalink`, `post_title`.

Rows are deduplicated by Reddit's fullname id (`t3_…` for posts, `t1_…` for comments), so you are
never charged twice for the same item.

### Input

| Field | Description |
| --- | --- |
| **Subreddits** | One or more of `programming`, `r/cooking`, or a full subreddit URL. |
| **Sort posts by** | `hot`, `new`, `top`, `rising`, `controversial`. |
| **Time range** | For `top` / `controversial`: hour, day, week, month, year, all. |
| **Max posts per subreddit** | Cap per subreddit (0 = as far as Reddit will page, ~1000). |
| **Also scrape comments** | Collect the comment tree under each post. |
| **Max comments per post** | Cap comments (incl. nested replies) per post. |
| **Include NSFW posts** | Uncheck to skip `over_18` posts. |
| **Proxy** | Residential (required — see below). |

### How it works

Reddit refuses plain HTTP requests to its JSON endpoints with a browser-challenge block page from
every IP tier (including a clean home IP) — it is a client-execution check, not IP reputation. This
Actor therefore opens a real Chromium browser, lets Reddit's challenge clear **once per subreddit**,
then reads Reddit's own JSON endpoints (`/r/<sub>/<sort>.json`, `/r/<sub>/comments/<id>/.json`) with
an in-page `fetch()`. That means clean, structured JSON — not fragile HTML scraping.

**Residential proxy is required.** Measured 2026-07-30: residential cleared the challenge on 20/20
distinct subreddits; datacenter got stuck on the interstitial (4/20). The default proxy setting is
already correct.

### Pricing

Pay per row returned (a post, or a comment when comment scraping is on). Deduplicated, and only
delivered rows are charged.

### Legality & ToS

This Actor collects **publicly available** content from Reddit. Use it in compliance with Reddit's
Terms of Service and User Agreement, and with applicable law. Comment and author data may constitute
personal data — how you store and use scraped data (including any personal data) is your
responsibility as the operator. Do not use the output for spam, harassment, or any purpose Reddit's
terms prohibit.

# Actor input Schema

## `subreddits` (type: `array`):

One or more subreddits to scrape. Accepts `programming`, `r/programming` or a full `https://www.reddit.com/r/programming/` URL.

## `sort` (type: `string`):

Which listing to pull. 'Top' and 'Controversial' respect the time range below.

## `time` (type: `string`):

Only applies when sorting by Top or Controversial.

## `maxPostsPerSubreddit` (type: `integer`):

Stop after this many posts for each subreddit. Set 0 for as many as Reddit will page through (typically ~1000).

## `includeComments` (type: `boolean`):

Collect the comment tree under each post as separate rows (type = "comment"). Slower and adds one charged row per comment returned.

## `maxCommentsPerPost` (type: `integer`):

Cap comments collected per post (includes nested replies). Only used when 'Also scrape comments' is on.

## `includeNsfw` (type: `boolean`):

Uncheck to skip posts flagged over\_18.

## `proxyConfiguration` (type: `object`):

**Residential proxy is required.** Measured 2026-07-30: residential clears Reddit's browser challenge 20/20; datacenter gets stuck on the `?js_challenge` interstitial (4/20). The default below is already correct — do not switch it to datacenter.

## `requestDelayMs` (type: `integer`):

Pacing between Reddit JSON calls. Lower is faster but more likely to be throttled.

## Actor input object example

```json
{
  "subreddits": [
    "programming"
  ],
  "sort": "hot",
  "time": "all",
  "maxPostsPerSubreddit": 50,
  "includeComments": false,
  "maxCommentsPerPost": 50,
  "includeNsfw": true,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  },
  "requestDelayMs": 700
}
```

# Actor output Schema

## `posts` (type: `string`):

Posts (title, author, selftext, score, upvote ratio, comment count, permalink) and, optionally, each post's comment tree (body, author, score, depth, parent).

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "subreddits": [
        "programming"
    ],
    "sort": "hot",
    "time": "all",
    "maxPostsPerSubreddit": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapersdelight/reddit-subreddit-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "subreddits": ["programming"],
    "sort": "hot",
    "time": "all",
    "maxPostsPerSubreddit": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("scrapersdelight/reddit-subreddit-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "subreddits": [
    "programming"
  ],
  "sort": "hot",
  "time": "all",
  "maxPostsPerSubreddit": 50
}' |
apify call scrapersdelight/reddit-subreddit-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scrapersdelight/reddit-subreddit-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/9x0eFpxHVYvtkg98C/builds/jtK9Z6supsTNMulYm/openapi.json
