# 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:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.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 a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Reddit Comments Scraper",
        "description": "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.",
        "version": "0.0",
        "x-build-id": "sCJTcicvCewngNHju"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/outspoken_strategy~reddit-comments-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-outspoken_strategy-reddit-comments-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/outspoken_strategy~reddit-comments-scraper/runs": {
            "post": {
                "operationId": "runs-sync-outspoken_strategy-reddit-comments-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/outspoken_strategy~reddit-comments-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-outspoken_strategy-reddit-comments-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "urls": {
                        "title": "Post URLs",
                        "type": "array",
                        "description": "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.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "startUrls": {
                        "title": "Post URLs (request list)",
                        "type": "array",
                        "description": "Alternative way to provide the post URLs as a request list of { \"url\": ... } objects. Merged with \"urls\" and de-duplicated by post.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "maxComments": {
                        "title": "Max comments per post",
                        "minimum": 1,
                        "maximum": 500,
                        "type": "integer",
                        "description": "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.",
                        "default": 100
                    },
                    "commentsSort": {
                        "title": "Comments sort",
                        "enum": [
                            "top",
                            "confidence",
                            "new",
                            "controversial",
                            "old",
                            "qa"
                        ],
                        "type": "string",
                        "description": "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\".",
                        "default": "top"
                    },
                    "includeReplies": {
                        "title": "Include nested replies",
                        "type": "boolean",
                        "description": "Include replies-to-comments (the full thread tree, with parentCommentId/depth set). Uncheck to keep only top-level comments on the post.",
                        "default": true
                    },
                    "includeSourcePost": {
                        "title": "Include the source post",
                        "type": "boolean",
                        "description": "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.",
                        "default": true
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Proxy to route traffic through. Reddit blocks most datacenter IPs, so residential proxies are strongly recommended.",
                        "default": {
                            "useApifyProxy": true,
                            "apifyProxyGroups": [
                                "RESIDENTIAL"
                            ],
                            "apifyProxyCountry": "US"
                        }
                    },
                    "headless": {
                        "title": "Run browser headless",
                        "type": "boolean",
                        "description": "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).",
                        "default": true
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
