# Reddit Comment Scraper Pro — Updated & Reliable (`newbs/reddit-comment-scraper`)

Reddit Comment Scraper Pro — updated 2025 & Shreddit-DOM compatible. Scrape full threads (comments + nested replies) with depth, timestamps, authors & paths. Export CSV/JSON/XLSX. Apify-ready, headless, proxy support, auto-pagination, smart rate-limit handling. No API key.

- **URL**: https://beta-securitybyobscurity.apify.com/newbs/reddit-comment-scraper.md
- **Developed by:** [Newbs](https://beta-securitybyobscurity.apify.com/newbs) (community)
- **Categories:** Social media, Developer tools, Automation
- **Stats:** 6 total users, 6 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

$29.99/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.
You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#rental-actors

# README

## Reddit Comment Scraper

Extract comments and replies from Reddit posts with full conversation threads preserved.

### 🎯 What does this actor do?

This actor scrapes comments from Reddit posts, capturing:

- All comments and nested replies in a tree structure
- Comment text, author, timestamp, and depth level
- Complete conversation threads with parent-child relationships
- Support for both top-level comments only or full reply chains

Perfect for:

- **Market Research** - Analyze customer opinions and feedback
- **Sentiment Analysis** - Understand community reactions
- **Content Analysis** - Study discussion patterns and trends
- **Community Monitoring** - Track conversations about your brand

### 📥 Input

| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| `postUrls` | Array | Yes | - | List of Reddit post URLs to scrape |
| `maxComments` | Number | No | 500 | Maximum number of comments to collect |
| `includeReplies` | Boolean | No | true | Whether to include nested replies |
| `sortBy` | String | No | "top" | Comment sort order (top, new, best, controversial) |

#### Example Input

```json
{
  "postUrls": [
    "https://www.reddit.com/r/technology/comments/example/discussion_thread/"
  ],
  "maxComments": 100,
  "includeReplies": true,
  "sortBy": "top"
}
```

### 📤 Output

The actor outputs **one row per comment** for clean Excel/CSV exports. Each comment (including replies) becomes a separate row with full context.

#### Output Format (Flattened for Easy Analysis)

Each row contains:

```json
{
  "postUrl": "https://www.reddit.com/r/...",
  "postTitle": "Post title here",
  "postAuthor": "original_poster",
  "postScore": "1234",
  "subreddit": "technology",
  
  "commentDepth": 0,
  "commentAuthor": "user1",
  "commentText": "This is the comment text",
  "commentTimestamp": "2024-01-15T10:30:00Z",
  "commentId": "abc123",
  
  "commentPath": "0",
  "parentPath": null,
  "isTopLevel": true,
  "replyCount": 3,
  
  "scrapedAt": "2024-01-15T12:00:00Z"
}
```

#### Output Fields Explained

**Post Context** (same for all comments from a post):

- **`postUrl`** - URL of the Reddit post
- **`postTitle`** - Title of the post
- **`postAuthor`** - Original post author
- **`subreddit`** - Subreddit name

**Comment Details**:

- **`commentDepth`** - Nesting level (0 = top-level, 1 = first reply, etc.)
- **`commentAuthor`** - Username of comment author
- **`commentText`** - The actual comment content
- **`commentTimestamp`** - When the comment was posted
- **`commentId`** - Reddit's comment ID

**Threading Information**:

- **`commentPath`** - Path showing position in thread (e.g., "0/2/1" = first comment → third reply → second sub-reply)
- **`parentPath`** - Path to parent comment (null for top-level)
- **`isTopLevel`** - Boolean indicating if it's a main comment
- **`replyCount`** - Number of direct replies to this comment

#### Example: How Threading Works

If a post has this structure:

```
Comment A (path: "0")
  └── Reply B (path: "0/0")
      └── Reply C (path: "0/0/0")
Comment D (path: "1")
  └── Reply E (path: "1/0")
```

You'll get 5 rows in your export:

1. Row for Comment A with `commentPath: "0"`, `parentPath: null`
2. Row for Reply B with `commentPath: "0/0"`, `parentPath: "0"`
3. Row for Reply C with `commentPath: "0/0/0"`, `parentPath: "0/0"`
4. Row for Comment D with `commentPath: "1"`, `parentPath: null`
5. Row for Reply E with `commentPath: "1/0"`, `parentPath: "1"`

#### Benefits of This Format

✅ **Excel/CSV Ready** - Each comment is a row, no nested JSON columns
✅ **Easy Filtering** - Filter by depth, author, or isTopLevel
✅ **Preserved Threading** - Use commentPath/parentPath to reconstruct conversations
✅ **Analysis Friendly** - Count comments per author, average reply depth, etc.

### 🚀 How to Use

#### Via Apify Console

1. Add Reddit post URLs to the `postUrls` array
2. Set `maxComments` to limit data collection (useful for large threads)
3. Toggle `includeReplies` based on your needs:
   - `true` - Get full conversation threads
   - `false` - Get only top-level comments
4. Choose `sortBy` to control comment ordering
5. Click "Run" to start scraping

#### Via API

```javascript
const input = {
  postUrls: [
    "https://www.reddit.com/r/AskReddit/comments/xyz/what_is_your_opinion/"
  ],
  maxComments: 200,
  includeReplies: true,
  sortBy: "best"
};

// Run via Apify API
const run = await client.actor("your-username/reddit-comment-scraper").call(input);
```

#### Processing Multiple Posts

You can scrape multiple posts in one run:

```json
{
  "postUrls": [
    "https://www.reddit.com/r/technology/comments/post1/",
    "https://www.reddit.com/r/science/comments/post2/",
    "https://www.reddit.com/r/gaming/comments/post3/"
  ],
  "maxComments": 100
}
```

### 💡 Use Cases

#### Market Research

Analyze product discussions and customer feedback:

- Track mentions of your brand
- Understand customer pain points
- Identify feature requests

#### Sentiment Analysis

Study community reactions:

- Measure response to announcements
- Track opinion trends over time
- Identify influential commenters

#### Content Strategy

Understand what resonates:

- Find popular discussion topics
- Identify content gaps
- Study engagement patterns

### ⚠️ Limitations

- Works with new Reddit interface (reddit.com)
- Respects Reddit's rate limits
- Some very deeply nested threads may require clicking "Continue thread" links
- Deleted/removed comments are skipped
- Maximum runtime: 60 minutes per run

### 🔧 Advanced Features

#### Comment Filtering

- Set `includeReplies: false` to get only top-level comments
- Use `maxComments` to limit data collection
- Comments are sorted according to `sortBy` parameter

#### Data Structure

- Nested reply structure preserves conversation context
- Each comment includes depth level for easy filtering
- Timestamps allow temporal analysis

### 📊 Example Analysis

With the scraped data, you can:

- Count replies per comment to find most engaging topics
- Analyze comment depth to understand conversation complexity
- Track author participation across threads
- Build word clouds from comment text
- Perform sentiment analysis on discussions

### 🆘 Support

Having issues? Check these common solutions:

1. **No comments found** - Verify the Reddit post URL is correct and public
2. **Timeout errors** - Reduce `maxComments` for very large threads
3. **Missing replies** - Ensure `includeReplies` is set to `true`

For additional support, please open an issue or contact support.

### 📝 Changelog

#### Version 1.0.0

- Initial release with Shreddit (new Reddit) support
- Full comment tree structure with nested replies
- Configurable comment limits and sorting
- Support for multiple posts in single run

# Actor input Schema

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

List of Reddit post URLs to scrape comments from. Use full URLs like https://www.reddit.com/r/subreddit/comments/id/title/

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

Maximum number of comments to collect per post. This includes nested replies if enabled. Use a lower number for faster runs.

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

When enabled, collects all nested replies maintaining the conversation tree structure. When disabled, only collects top-level comments.

## `sortBy` (type: `string`):

How to sort comments before collection. This affects which comments are collected when using maxComments limit.

## `proxy` (type: `object`):

Select proxy type. RESIDENTIAL proxies recommended for best results with Reddit. Required when running on Apify platform to avoid 403 blocks.

## Actor input object example

```json
{
  "postUrls": [
    "https://www.reddit.com/r/AskMec/comments/14990m6/les_applications_de_rencontres_fonctionnent_telles/"
  ],
  "maxComments": 500,
  "includeReplies": true,
  "sortBy": "top",
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  }
}
```

# 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/AskMec/comments/14990m6/les_applications_de_rencontres_fonctionnent_telles/"
    ],
    "maxComments": 500,
    "sortBy": "top"
};

// Run the Actor and wait for it to finish
const run = await client.actor("newbs/reddit-comment-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/AskMec/comments/14990m6/les_applications_de_rencontres_fonctionnent_telles/"],
    "maxComments": 500,
    "sortBy": "top",
}

# Run the Actor and wait for it to finish
run = client.actor("newbs/reddit-comment-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 '{
  "postUrls": [
    "https://www.reddit.com/r/AskMec/comments/14990m6/les_applications_de_rencontres_fonctionnent_telles/"
  ],
  "maxComments": 500,
  "sortBy": "top"
}' |
apify call newbs/reddit-comment-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Reddit Comment Scraper Pro — Updated & Reliable",
        "description": "Reddit Comment Scraper Pro — updated 2025 & Shreddit-DOM compatible. Scrape full threads (comments + nested replies) with depth, timestamps, authors & paths. Export CSV/JSON/XLSX. Apify-ready, headless, proxy support, auto-pagination, smart rate-limit handling. No API key.",
        "version": "1.0",
        "x-build-id": "GDppDUrQYKbUDT2to"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/newbs~reddit-comment-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-newbs-reddit-comment-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/newbs~reddit-comment-scraper/runs": {
            "post": {
                "operationId": "runs-sync-newbs-reddit-comment-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/newbs~reddit-comment-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-newbs-reddit-comment-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",
                "required": [
                    "postUrls"
                ],
                "properties": {
                    "postUrls": {
                        "title": "Reddit Post URLs",
                        "minItems": 1,
                        "uniqueItems": true,
                        "type": "array",
                        "description": "List of Reddit post URLs to scrape comments from. Use full URLs like https://www.reddit.com/r/subreddit/comments/id/title/",
                        "items": {
                            "type": "string",
                            "pattern": "^https://www\\.reddit\\.com/r/[^/]+/comments/[^/]+/.*$"
                        }
                    },
                    "maxComments": {
                        "title": "Maximum Comments",
                        "minimum": 1,
                        "maximum": 5000,
                        "type": "integer",
                        "description": "Maximum number of comments to collect per post. This includes nested replies if enabled. Use a lower number for faster runs.",
                        "default": 500
                    },
                    "includeReplies": {
                        "title": "Include Nested Replies",
                        "type": "boolean",
                        "description": "When enabled, collects all nested replies maintaining the conversation tree structure. When disabled, only collects top-level comments.",
                        "default": true
                    },
                    "sortBy": {
                        "title": "Sort Comments By",
                        "enum": [
                            "top",
                            "best",
                            "new",
                            "controversial",
                            "old",
                            "qa"
                        ],
                        "type": "string",
                        "description": "How to sort comments before collection. This affects which comments are collected when using maxComments limit.",
                        "default": "top"
                    },
                    "proxy": {
                        "title": "Proxy Configuration",
                        "type": "object",
                        "description": "Select proxy type. RESIDENTIAL proxies recommended for best results with Reddit. Required when running on Apify platform to avoid 403 blocks.",
                        "default": {
                            "useApifyProxy": true,
                            "apifyProxyGroups": [
                                "RESIDENTIAL"
                            ],
                            "apifyProxyCountry": "US"
                        }
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
