# Reddit Comment Tree Scraper (`scrapingdino/reddit-comment-tree-scraper`) Actor

Pull full Reddit comment trees from post URLs — sorted threads with author, score, and nesting intact. Ideal for sentiment pipelines and community research. $0.50 per 1,000 comments.

- **URL**: https://apify.com/scrapingdino/reddit-comment-tree-scraper.md
- **Developed by:** [Scraping Dino](https://apify.com/scrapingdino) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
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 Comment Tree Scraper - Scrape Full Thread Comments by Sort

### Overview

The **Reddit Comment Tree Scraper** extracts comments from Reddit posts using full post URLs. Choose sort order (best/confidence, top, new, controversial, old, or Q\&A) and cap results per post — ideal when you need discussion text, not just post metadata.

Designed for sentiment analysts, community managers, NLP engineers, and researchers studying threaded conversations. Point it at product launches, brand crises, AMAs, or research threads and receive **clean, structured JSON** for every comment collected.

Pagination and per-post limits keep large threads manageable while preserving author, score, subreddit, timestamps, and body text for downstream analysis.

### Features

- Multi-URL batch scraping of Reddit comment trees
- Sort modes: `confidence` (best), `top`, `new`, `controversial`, `old`, `qa`
- Configurable `maxResults` per post (1–500)
- Structured comment fields: id, author, score, body, permalink, timestamps
- Concurrent workers across posts for faster runs
- Per-post error rows so one failure does not abort the batch
- Clean JSON ready for NLP, moderation review, or BI tools

### Use Cases

- **Brand monitoring** — Capture customer sentiment under viral posts
- **Market research** — Mine product feedback and objections in threads
- **Competitor analysis** — Read reactions to competitor launches
- **Content research** — Pull quotable discussion for articles or reports
- **AI training datasets** — Build conversation corpora with ratings/scores
- **Academic research** — Study discourse structure and toxicity signals
- **Trend monitoring** — Track emerging themes in high-engagement threads
- **Data analytics** — Score comment velocity and engagement over time

### Input

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `postUrls` | array of strings | **Yes** | — | Reddit post URLs to scrape comments from (one per line). |
| `sort` | string | No | `"confidence"` | Comment sort: `confidence`, `top`, `new`, `controversial`, `old`, or `qa`. |
| `maxResults` | integer | No | `50` | Max comments per post (1–500). |

**How parameters affect the run:** `sort` changes which comments appear first and which get truncated when `maxResults` is hit. Higher `maxResults` increases API volume and runtime.

#### Example input

```json
{
  "postUrls": [
    "https://www.reddit.com/r/AskReddit/comments/1xyz789/whats_the_best_productivity_app_youve_used/"
  ],
  "sort": "top",
  "maxResults": 100
}
```

### Output

Each row is a comment (or error) with listing summary fields:

| Field | Type | Description |
|---|---|---|
| `type` | string | Typically `"comment"` or `"error"` |
| `sourceUrl` | string | Source post URL |
| `sort` | string | Sort used for the request |
| `id` | string | null | Comment ID |
| `name` | string | null | Fullname (`t1_...`) |
| `kind` | string | null | Reddit kind |
| `title` | string | null | Parent link title when present |
| `author` | string | null | Comment author |
| `subreddit` | string | null | Subreddit |
| `score` | number | null | Comment score |
| `numComments` | number | null | Usually null for comments |
| `createdUtc` | number | string | null | Creation time |
| `permalink` | string | null | Comment permalink |
| `url` | string | null | Related URL if present |
| `body` | string | null | Comment text (may be truncated to ~500 chars in summary mapping) |

Optional / sparse fields may be `null` depending on API payload shape.

### Example Output

```json
[
  {
    "type": "comment",
    "sourceUrl": "https://www.reddit.com/r/AskReddit/comments/1xyz789/whats_the_best_productivity_app_youve_used/",
    "sort": "top",
    "id": "kx91abc",
    "name": "t1_kx91abc",
    "kind": "t1",
    "title": "What's the best productivity app you've used?",
    "author": "deepworkfan",
    "subreddit": "AskReddit",
    "score": 4821,
    "numComments": null,
    "createdUtc": 1718210000,
    "permalink": "https://www.reddit.com/r/AskReddit/comments/1xyz789/.../kx91abc/",
    "url": null,
    "body": "After trying dozens of tools, the only one that stuck for me is a simple markdown notes app plus a weekly review ritual."
  }
]
```

### Related Scrapers

- **Reddit Post Scraper** — Post metadata and duplicates for the same URLs
- **Reddit Search Scraper** — Find posts first, then scrape their comments
- **Reddit User Comments Scraper** — Comments by username across Reddit
- **Reddit Subreddit Scraper** — Optional community comments plus rules/info

# Actor input Schema

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

List of Reddit post URLs to scrape comments from. Enter one URL per line.

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

How to sort comments: confidence (best), top, new, controversial, old, or qa.

## `maxResults` (type: `integer`):

Maximum number of comments to fetch per post.

## Actor input object example

```json
{
  "postUrls": [
    "https://www.reddit.com/r/oddlysatisfying/comments/1tg4gv5/a_turtle_giving_itself_a_scrub/"
  ],
  "sort": "confidence",
  "maxResults": 50
}
```

# Actor output Schema

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

Default dataset items produced by this Actor.

# 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/oddlysatisfying/comments/1tg4gv5/a_turtle_giving_itself_a_scrub/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapingdino/reddit-comment-tree-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/oddlysatisfying/comments/1tg4gv5/a_turtle_giving_itself_a_scrub/"] }

# Run the Actor and wait for it to finish
run = client.actor("scrapingdino/reddit-comment-tree-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/oddlysatisfying/comments/1tg4gv5/a_turtle_giving_itself_a_scrub/"
  ]
}' |
apify call scrapingdino/reddit-comment-tree-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scrapingdino/reddit-comment-tree-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/FCy7Vyv0Z3b4PSMhj/builds/riS2JctAlAZ9mRXLd/openapi.json
