# Reddit Comments Scraper (`outspoken_strategy/reddit-comments-scraper`) Actor

Scrape the comments of one or MANY Reddit posts in a single run. Returns text, author, score, timestamps and thread structure (parent/depth), plus the source post itself. No login needed.

- **URL**: https://apify.com/outspoken\_strategy/reddit-comments-scraper.md
- **Developed by:** [code craker](https://apify.com/outspoken_strategy) (community)
- **Categories:** Social media, News, E-commerce
- **Stats:** 2 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $15.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 Comments Scraper

Apify actor that scrapes the comments of one or **many** Reddit posts in a single run
and exports them as structured data — no login, no cookies.

It scrapes the classic old.reddit.com comment pages, which render up to 500 comments
in one request and have had stable markup for a decade. (Reddit hard-blocks its public
`.json` endpoints for unauthenticated clients, so those are not usable.)

Pages are fetched over plain HTTP first (fast and cheap); when Reddit fingerprint-blocks
that (it does for most proxy exit IPs), the actor automatically escalates to a real
Chrome browser for the rest of the run, relaunching on fresh preflighted proxy IPs as
needed.

### Features

- **Batched**: pass many post URLs and they are all scraped in ONE actor run
  (`maxComments` applies per post). Results are pushed after each post, so an abort
  or timeout keeps everything collected so far.
- Any post reference works: `www.reddit.com/r/sub/comments/abc123/slug/`,
  old.reddit links, `redd.it/abc123` short links, or a bare post id.
- Full thread structure: `parentCommentId` + `depth` on every comment, or
  top-level comments only (`includeReplies: false`).
- Comment sort control (`top`, `confidence`/best, `new`, `controversial`, `old`, `qa`) —
  matters when a thread has more comments than `maxComments`.
- The source post itself is emitted too (flagged `is_source_post: true`) with title,
  selftext, score and comment count; disable with `includeSourcePost: false`.
- Deleted/removed comments are skipped (their replies still come through).
- NSFW interstitial bypassed automatically (`over18` cookie).
- When a run ends with 0 results, the last page fetched is saved as `DEBUG_HTML`
  in the run's key-value store.

### Input

```json
{
    "urls": [
        "https://www.reddit.com/r/zimbabwe/comments/1abcd2/econet_results/",
        "https://redd.it/1wxyz9"
    ],
    "maxComments": 100,
    "commentsSort": "top",
    "includeReplies": true,
    "includeSourcePost": true,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "US"
    }
}
```

`startUrls` (`[{ "url": ... }]`) is accepted as an alternative to `urls` and merged
with it. `resultsLimit` is accepted as an alias for `maxComments`.

**Limit**: old.reddit renders at most ~500 comments per page and the deeper
"load more comments" stubs require the blocked JSON API, so `maxComments` caps at 500.
With `commentsSort: "top"` you always get the highest-scored comments first.

### Output

One dataset item per comment. Every item carries `postId` / `postName` / `postUrl` /
`inputUrl`, so comments from a multi-post run can always be attributed back to their
source post.

```json
{
    "id": "mhkp8wz",
    "name": "t1_mhkp8wz",
    "url": "https://www.reddit.com/r/zimbabwe/comments/1abcd2/econet_results/mhkp8wz/",
    "text": "Full text of the comment...",
    "author": "some_user",
    "authorProfileUrl": "https://www.reddit.com/user/some_user",
    "isSubmitter": false,
    "subreddit": "zimbabwe",
    "score": 42,
    "repliesCount": 3,
    "gildings": 0,
    "stickied": false,
    "parentCommentId": null,
    "depth": 0,
    "created_at": "2026-07-01T10:12:45.000Z",
    "createdUtc": 1782900765,
    "postId": "1abcd2",
    "postName": "t3_1abcd2",
    "postUrl": "https://www.reddit.com/r/zimbabwe/comments/1abcd2/econet_results/",
    "inputUrl": "https://www.reddit.com/r/zimbabwe/comments/1abcd2/econet_results/",
    "commentsSort": "top",
    "is_source_post": false
}
```

- `parentCommentId` is `null` for a top-level comment on the post; otherwise the id
  of the comment it replies to (same semantics as our Twitter comments actor).
- `score` is `null` while Reddit still hides a fresh comment's score.
- The source post item has `is_source_post: true` and the post fields
  (`title`, `text` = selftext, `score`, `numComments`, ...).

### Integration (scraping-tool)

Batched, like Facebook/TikTok/Twitter comments in `scrapeCommentsForPostsBatched`.
Add a branch to `scrapingService.scrapeCommentsBatch`:

```js
} else if (actor === 'outspoken_strategy/reddit-comments-scraper') {
    delete input.startUrls;
    input.urls = urls;
    input.maxComments = cappedComments(input.maxComments ?? resultsLimit);
    input.includeSourcePost = input.includeSourcePost ?? false;
    input.includeReplies = input.includeReplies ?? false; // match FB: top-level only
    input.proxyConfiguration = input.proxyConfiguration ?? { useApifyProxy: true, apifyProxyGroups: ['RESIDENTIAL'], apifyProxyCountry: 'US' };
}
```

Attribution in `_matchCommentToPost` (platform `reddit`): match on `item.postUrl`,
`item.inputUrl` or `item.postId` — a good `_postMatchKey` is the post id extracted
with `/\/comments\/([a-z0-9]+)/i`.

Normalization hints: `likesCount` ← `score` (may be null), `repliesCount` is already
named, `createdTime` ← `created_at`, `parentCommentId` is already named, and author
fields are flat (`author`, `authorProfileUrl`).

### Local development

```bash
npm install
echo '{ "urls": ["https://redd.it/1jadp27"], "maxComments": 25, "proxyConfiguration": { "useApifyProxy": false } }' > storage/key_value_stores/default/INPUT.json
npm start
```

Deploy with `apify push`.

# Actor input Schema

## `urls` (type: `array`):

URLs of the Reddit posts whose comments you want to scrape — one or MANY posts per run. Any form works: www.reddit.com/r/sub/comments/abc123/slug/, old.reddit.com links, redd.it/abc123 short links, or a bare post id like "abc123". De-duplicated by post.

## `startUrls` (type: `array`):

Alternative way to provide the post URLs as a request list of { "url": ... } objects. Merged with "urls" and de-duplicated by post.

## `maxComments` (type: `integer`):

Maximum number of comments to fetch PER post URL. The source post itself is also emitted (flagged is\_source\_post) and does not count towards this limit. Capped at 500 — Reddit renders at most 500 comments per page and the deeper "load more comments" stubs require the blocked JSON API.

## `commentsSort` (type: `string`):

Which comments Reddit puts first — matters when a thread has more comments than maxComments. "top" (highest score), "confidence" (Reddit's default "best"), "new", "controversial", "old" or "qa".

## `includeReplies` (type: `boolean`):

Include replies-to-comments (the full thread tree, with parentCommentId/depth set). Uncheck to keep only top-level comments on the post.

## `includeSourcePost` (type: `boolean`):

Also emit one dataset item for the post itself (flagged is\_source\_post: true) with its title, selftext, score and comment count. Uncheck to get comments only.

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

Proxy to route traffic through. Reddit blocks most datacenter IPs, so residential proxies are strongly recommended.

## `headless` (type: `boolean`):

The actor fetches over plain HTTP and only falls back to a Chrome browser when Reddit blocks it. Uncheck to run that fallback browser headed (useful only for local debugging).

## Actor input object example

```json
{
  "urls": [
    "https://www.reddit.com/r/mildlyinfuriating/comments/1jadp27/two_amazon_robots_with_equal_artificial/"
  ],
  "startUrls": [],
  "maxComments": 100,
  "commentsSort": "top",
  "includeReplies": true,
  "includeSourcePost": true,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  },
  "headless": true
}
```

# 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 = {
    "urls": [
        "https://www.reddit.com/r/mildlyinfuriating/comments/1jadp27/two_amazon_robots_with_equal_artificial/"
    ],
    "startUrls": [],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "US"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("outspoken_strategy/reddit-comments-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 = {
    "urls": ["https://www.reddit.com/r/mildlyinfuriating/comments/1jadp27/two_amazon_robots_with_equal_artificial/"],
    "startUrls": [],
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "US",
    },
}

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

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

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

```

## CLI example

```bash
echo '{
  "urls": [
    "https://www.reddit.com/r/mildlyinfuriating/comments/1jadp27/two_amazon_robots_with_equal_artificial/"
  ],
  "startUrls": [],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  }
}' |
apify call outspoken_strategy/reddit-comments-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=outspoken_strategy/reddit-comments-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/kfravDQONWrCwrtUd/builds/sCJTcicvCewngNHju/openapi.json
