# Reddit Comments Scraper - Threads & Nested Replies by URL (`renzomacar/reddit-comments-scraper`) Actor

Scrape every comment of Reddit posts by URL, nested replies included (also the ones Reddit folds behind "more replies"): text, author, score, date, link, depth and parent ID, so the thread can be rebuilt. Up to 500 per post. No login or API key.

- **URL**: https://apify.com/renzomacar/reddit-comments-scraper.md
- **Developed by:** [Renzo Madueno](https://apify.com/renzomacar) (community)
- **Categories:** Social media, AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 comments

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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Reddit Comments Scraper

Paste links to Reddit posts and get every comment the thread shows as one row each: text, author, score, date, a link to the comment, and where it sits in the conversation (`depth` and `parentId`). No Reddit account, no API key, no login.

### What you give it

| Field | What it does |
|---|---|
| `postUrls` | Links to Reddit posts. `www.reddit.com`, `old.reddit.com` and links with tracking parameters all work. A link to a single comment is read as its whole thread. |
| `maxCommentsPerPost` | Upper limit per post, 1 to 500. Default 100. |

```json
{
  "postUrls": [
    "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/"
  ],
  "maxCommentsPerPost": 200
}
```

`urls` and `startUrls` are accepted as other names for `postUrls`, and each of them can be a list, a block of text with one link per line, or a list of `{ "url": "..." }` objects.

### What you get

One row per comment.

| Field | Type | Meaning |
|---|---|---|
| `dataType` | string | Always `comment` |
| `redditId` | string | Reddit's ID of the comment |
| `postTitle` | string | Title of the post the comment belongs to |
| `postUrl` | string | Link to the post |
| `subreddit` | string | Community the post is in |
| `author` | string | Username, or `[deleted]` |
| `body` | string | Comment text, up to 5,000 characters |
| `score` | integer or null | Net upvotes. `null` when Reddit hides it or the comment is deleted |
| `depth` | integer | 0 for a top-level comment, 1 for a reply to it, and so on |
| `parentId` | string | `redditId` of the comment this one answers. Empty for top-level comments |
| `url` | string | Link to the comment itself |
| `createdUtc` | string | When it was posted, UTC |
| `scrapedAt` | string | When this row was collected |

A few more columns (`upvoteRatio`, `commentCount`, `flair`, `domain`, `isStickied`, `postType`) are present and empty on comment rows. They exist so the output has the same columns as [Reddit Scraper](https://apify.com/renzomacar/reddit-scraper) and both datasets can be merged without mapping.

Example row:

```json
{
  "dataType": "comment",
  "redditId": "t1_c60o0iw",
  "postTitle": "I am Barack Obama, President of the United States -- AMA",
  "author": "example_user",
  "subreddit": "IAmA",
  "score": 2816,
  "body": "What is the first thing you'll do on November 7th, win or lose?",
  "url": "https://www.reddit.com/r/IAmA/comments/z1c9z/comment/c60o0iw/",
  "postUrl": "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states",
  "createdUtc": "2012-08-29T20:35:07.000Z",
  "parentId": "",
  "depth": 0
}
```

The values above illustrate the shape; a run returns what the thread holds at that moment.

### Rebuilding the conversation

Rows arrive in thread order: a top-level comment, then the replies shown under it, then the next top-level comment. To rebuild the tree, group by `parentId`. To keep only the first level, filter `depth = 0`. To find the comments that started the longest exchanges, count rows per `parentId`.

### Limits, stated plainly

- **Up to 500 comments per post.** Comments are read in the order the thread shows them with the best first, so on a very large thread you get the most upvoted part of it, not all of it.
- **Folded replies are opened.** Where Reddit shows "3 more replies", the Actor opens them and puts each reply under the comment it answers. Deleted and removed comments are not returned, so the total can be below the number Reddit shows on the post (Reddit counts those too).
- **A post can come back empty.** If Reddit does not serve the thread of a post on that try, the run saves nothing for it, charges nothing for it, and names the post in the log and the status message.
- Private, quarantined and removed posts return nothing. The run's status message lists every link that gave no comments and why.

### Price

Pay per comment delivered, with no fee per post and no start fee. A link that returns no comments costs nothing, and a run that delivers no comment at all ends as failed instead of looking like a success. You can set a maximum cost per run in the run options: the run stops when it is reached. The current amount is on the Pricing tab.

### Posts, subreddits and search

This Actor does one thing: comments of the posts you name. To collect posts from a subreddit, search Reddit by keyword, or get posts together with their comments, use [Reddit Scraper](https://apify.com/renzomacar/reddit-scraper). The comment rows are the same in both.

### Questions

**Does it need my Reddit login?** No. It reads public threads only.

**Can I run it on a schedule?** Yes. Save the input as a task and schedule it; each run returns the thread as it is at that time, so new comments show up in the next run.

**The same link twice?** Duplicate links in the input are read once.

**A link was skipped.** Text that is not a link to a post (a subreddit link, a user profile) is skipped and listed in the run's status message.

# Actor input Schema

## `postUrls` (type: `array`):

Links to Reddit posts, one per line. Any form works: www.reddit.com, old.reddit.com, with or without tracking parameters. A link to a single comment returns that comment's branch.

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

Stop after this many comments for each post. Comments are read in the order the thread shows them (best first), replies included.

## Actor input object example

```json
{
  "postUrls": [
    "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/"
  ],
  "maxCommentsPerPost": 100
}
```

# Actor output Schema

## `results` (type: `string`):

One row per comment.

# 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 = {
    "postUrls": [
        "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("renzomacar/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 = { "postUrls": ["https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/"] }

# Run the Actor and wait for it to finish
run = client.actor("renzomacar/reddit-comments-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 '{
  "postUrls": [
    "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/"
  ]
}' |
apify call renzomacar/reddit-comments-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,renzomacar/reddit-comments-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/Ps3LLrAmoBmfjV1Al/builds/quJKxWcBmMdL9jHbc/openapi.json
