# Reddit Comments Scraper (`xtracto/reddit-comment-tree`) Actor

Fetch a Reddit post by URL or '<sub>/\<post_id>' shorthand, with full comments tree.

- **URL**: https://apify.com/xtracto/reddit-comment-tree.md
- **Developed by:** [Farhan Febrian Nauval](https://apify.com/xtracto) (community)
- **Categories:** Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.25 / 1,000 comments

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

Scrape every comment of one or many Reddit posts, nested replies included. You get one row per comment with its parent, depth, score, author, text and link, in the same thread order you see on Reddit. No Reddit account, no app registration, no API key.

### Why use this actor

- **The whole tree, not just the first page.** Reddit shows about 25 comments and hides the rest behind "more replies" and "view more comments". The actor opens all of them, so deep threads come back complete.
- **Many posts in one run.** Paste a list of post URLs; each post is read on its own connection.
- **Ready for analysis.** One flat row per comment with `parentId` and `depth`, so you can rebuild the tree, count replies, or feed the text to sentiment and topic tools without reshaping JSON.
- **Sort and filters like on Reddit.** Choose Best, Top, New, Controversial, Old or Q\&A, limit the reply depth, and keep only comments above a minimum score.
- **Post context on every row:** title, author, score, comment count and link of the post the comment belongs to.
- **Pay only for comments.** Posts that cannot be read are listed in the run status and never charged.

### Use cases

- Brand and product research: what people say about a product launch, a competitor or a feature.
- Sentiment and topic analysis of a discussion, AMA or support thread.
- Collecting questions and answers from AMAs and "ask" communities.
- Building datasets of real conversations for training or evaluating AI models.
- Archiving the discussion around an event before comments are deleted.

### Input

```json
{
  "posts": [
    "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/"
  ],
  "maxCommentsPerPost": 300,
  "sort": "top",
  "maxDepth": null,
  "minScore": null
}
```

| Field | Type | Description |
|---|---|---|
| `posts` | array of strings | Post URLs (`www.reddit.com`, `old.reddit.com`, `redd.it` short links) or `subreddit/postId`. |
| `maxCommentsPerPost` | integer | Stop after this many comments per post. `0` = every comment the post shows. Default `500`. |
| `sort` | string | `default` (the post's suggested sort), `best`, `top`, `new`, `controversial`, `old` or `qa`. It decides which comments come first when you set a limit. |
| `maxDepth` | integer | `0` = top-level comments only, `1` = plus direct replies, and so on. Empty = the full tree. |
| `minScore` | integer | Keep only comments with at least this score. Empty = keep all. |
| `proxyConfiguration` | object | Reddit blocks datacenter addresses, so a Residential proxy is used. It is set for you. |

### Output

One row per comment, in thread order (a comment is followed by its replies). Real rows from a run on 14 Nov 2026 with `sort: "top"`:

```json
{
  "commentId": "c60pmox",
  "parentId": "t1_c60o0iw",
  "isTopLevel": false,
  "depth": 1,
  "position": 2,
  "author": "delmar15",
  "isSubmitter": false,
  "isDeleted": false,
  "score": 2574,
  "body": "He said he would do an AMA for 30 min. That looks like 30 min of answering questions.",
  "createdAt": "2012-08-29T23:45:38+00:00",
  "permalink": "https://www.reddit.com/r/IAmA/comments/z1c9z/comment/c60pmox/",
  "postId": "z1c9z",
  "postTitle": "I am Barack Obama, President of the United States -- AMA",
  "postAuthor": "PresidentObama",
  "postScore": 216186,
  "postCommentCount": 22715,
  "postCreatedAt": "2012-08-29T20:01:36+00:00",
  "subreddit": "IAmA",
  "postUrl": "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/",
  "_input": "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/",
  "_source": "S3-shreddit",
  "_scrapedAt": "2026-11-14T21:07:42+00:00"
}
```

| Field | Type | Description |
|---|---|---|
| `commentId` | string | Reddit comment id. |
| `parentId` | string | `t1_<id>` of the parent comment, or `t3_<postId>` for a top-level comment. |
| `isTopLevel` | boolean | `true` when the comment replies to the post itself. |
| `depth` | integer | 0 for top-level comments, 1 for their replies, and so on. |
| `position` | integer | Order of the comment in the thread (1 = first). |
| `author` | string | Username, or `[deleted]`. |
| `isSubmitter` | boolean | `true` when the comment is written by the author of the post. |
| `isDeleted` | boolean | `true` for deleted or removed comments (kept so that their replies still have a parent). |
| `score` | integer or null | Upvotes minus downvotes. Reddit hides the score of some comments. |
| `body` | string | Comment text; paragraphs are separated by new lines. |
| `createdAt` | string (ISO date) | When the comment was posted (UTC). |
| `permalink` | string | Link to the comment. |
| `postId`, `postTitle`, `postAuthor`, `postScore`, `postCommentCount`, `postCreatedAt`, `subreddit`, `postUrl` | | The post the comment belongs to. |
| `_input`, `_source`, `_scrapedAt` | string | Your input value, the method that answered, and when the row was collected. |

### Notes and limits

- Speed: about 10 comments per second for each post. Several posts are read at the same time.
- `postCommentCount` is Reddit's own count. It includes removed and spam-filtered comments that Reddit no longer shows, so a complete run usually returns fewer rows than that number.
- With a limit, the actor reads the thread top-down in the chosen sort, so you get the highest comments of the thread and their first replies.
- Private, quarantined and removed posts cannot be read; they are listed in the run status and not charged.

# Actor input Schema

## `posts` (type: `array`):

Post URLs (www.reddit.com, old.reddit.com, redd.it short links) or `subreddit/postId`. Each post is read with its whole comment tree.

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

Stop after this many comments per post. `0` = all comments the post shows. Large threads take about one second per 10 comments.

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

Comment order, same as the sort menu on Reddit. It decides which comments come first when you set a limit.

## `maxDepth` (type: `integer`):

`0` = top-level comments only, `1` = plus direct replies, and so on. Leave empty for the full tree.

## `minScore` (type: `integer`):

Keep only comments with at least this score (upvotes minus downvotes). Leave empty to keep all.

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

Reddit blocks datacenter addresses, so a Residential proxy is required. It is set for you.

## Actor input object example

```json
{
  "posts": [
    "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/"
  ],
  "maxCommentsPerPost": 100,
  "sort": "default",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# 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 = {
    "posts": [
        "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/"
    ],
    "maxCommentsPerPost": 100,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("xtracto/reddit-comment-tree").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 = {
    "posts": ["https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/"],
    "maxCommentsPerPost": 100,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("xtracto/reddit-comment-tree").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 '{
  "posts": [
    "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/"
  ],
  "maxCommentsPerPost": 100,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call xtracto/reddit-comment-tree --silent --output-dataset

```

## MCP server setup

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

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/bLYprlhkYcZ5lP2K7/builds/bBMMp095ezNzMirF7/openapi.json
