# Reddit Comments Scraper (`khadinakbar/reddit-comments-scraper`) Actor

Scrape Reddit comment threads from post URLs. Returns comment text, author, score, parent and reply relationships, timestamps, and post metadata. JSON for MCP/API workflows.

- **URL**: https://apify.com/khadinakbar/reddit-comments-scraper.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** Social media, AI, MCP servers
- **Features:** Limited permissions
- **Stats:** 16 total users, 4 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 comment scrapeds

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

### What is Reddit Comments Scraper?

Reddit Comments Scraper is an Apify Actor for collecting Reddit comment threads from a thread URL, subreddit, user profile, or keyword. It accepts one or more inputs in `queries`, and each input produces comment records in a flat dataset where one record means one scraped comment. The returned fields include comment text, author, score, parent and reply relationships, timestamps, post metadata, and source metadata, so the output is ready for MCP, API, analytics, and LLM workflows.

### Best fit and connected workflows

This Actor fits workflows that start with Reddit sources and need comment-level JSON:

- Thread analysis from a specific Reddit post URL, where `parentId`, `depth`, `threadRelation`, and `numReplies` help reconstruct the reply tree.
- Subreddit monitoring, where `r/name` or a subreddit name returns recent comments in a flat feed.
- User comment review, where a user profile input returns that user's comments with the same comment-level schema.
- Keyword-led discovery, where a search term finds matching threads and returns their comments.
- MCP-based agent flows, where an AI tool can pass a Reddit reference and receive structured comments for summarization, extraction, or classification.

This Actor is designed as a focused standalone workflow.

### Practical scenario

Maya, a product researcher, has a Reddit thread URL, the subreddit name, and a keyword used by customers. She sends those three values in `queries` and keeps `mode` on `auto`. The dataset returns comment text, author, score, created time, permalink, and the post title for each comment. Maya uses `score`, `depth`, and `parentId` to identify the strongest reply chain, then follows the `permalink` to review context before sharing a summary with her team.

### Input fields

| Field | Type | Purpose |
|---|---|---|
| `queries` | array | Reddit sources to scrape comments from. Supports thread URLs, subreddits, user profiles, and keywords. Required. |
| `mode` | string | Interprets each `queries` item as `auto`, `thread`, `subreddit`, `user`, or `search`. |
| `maxComments` | integer | Caps the total number of comments returned across all inputs. |
| `sort` | string | Orders comments in a thread by Reddit sort: `top`, `suitable`, `new`, `controversial`, `old`, or `qa`. |
| `includeReplies` | boolean | Expands nested replies and collapsed comment stubs for thread and keyword inputs. |
| `maxDepth` | integer | Sets the maximum reply depth to traverse. |
| `responseFormat` | string | Chooses `concise` or `detailed` record shape. |
| `filterCommentsByKeyword` | boolean | In search mode, returns only comments containing the keyword when enabled. |
| `proxy` | object | Proxy configuration, with Apify Residential proxies as the default. |
| `redditClientId` | string | Optional Reddit app client ID for owner-supplied credentials. |
| `redditClientSecret` | string | Optional Reddit app client secret for owner-supplied credentials. |

#### Focused JSON input example

```json
{
  "queries": [
    "https://www.reddit.com/r/technology/comments/1abcd2e/some_thread/",
    "r/MachineLearning",
    "u/spez",
    "ChatGPT alternatives"
  ],
  "mode": "auto",
  "maxComments": 50,
  "sort": "top",
  "includeReplies": true,
  "maxDepth": 5,
  "responseFormat": "concise",
  "filterCommentsByKeyword": false,
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
```

### Output fields

The default dataset stores one item per comment. In `concise` mode, the core fields are compact and agent-friendly. In `detailed` mode, additional metadata is included.

| Field | Type | Purpose |
|---|---|---|
| `commentId` | string | Comment identifier. |
| `fullId` | string | Full comment identifier. |
| `parentId` | string | Parent comment or post relationship. |
| `postId` | string | Reddit post identifier. |
| `subreddit` | string | Subreddit name. |
| `postTitle` | string | Post title. |
| `postUrl` | string | Reddit post URL. |
| `author` | string | Comment author. |
| `body` | string | Comment text. |
| `score` | integer | Comment score. |
| `depth` | integer | Reply depth. |
| `isSubmitter` | boolean | Indicates whether the commenter is the post author. |
| `isEdited` | boolean | Indicates whether the comment was edited. |
| `createdAt` | string | Comment creation time. |
| `editedAt` | string | Edit time, when present. |
| `permalink` | string | Direct comment link. |
| `awardsCount` | integer | Award count. |
| `numReplies` | integer | Number of replies. |
| `inputMode` | string | Routed input mode used for the record. |
| `sourceInput` | string | Original query value. |
| `source` | string | Data source used to serve the record. |
| `bodyHtml` | string | HTML body in detailed mode. |
| `authorFlair` | string | Author flair in detailed mode. |
| `controversiality` | integer | Reddit controversiality value in detailed mode. |
| `stickied` | boolean | Stickied flag in detailed mode. |
| `distinguished` | string | Distinguished value. |
| `gilded` | integer | Gilded count in detailed mode. |
| `threadRelation` | string | Thread relationship label. |
| `_partial` | boolean | Partial record flag. |

#### Illustrative output record

```json
{
  "commentId": "abc123",
  "fullId": "t1_abc123",
  "parentId": "t3_1abcd2e",
  "postId": "1abcd2e",
  "subreddit": "technology",
  "postTitle": "Some interesting thread",
  "postUrl": "https://www.reddit.com/r/technology/comments/1abcd2e/some_thread/",
  "author": "example_user",
  "body": "This is the comment text.",
  "score": 142,
  "depth": 0,
  "isSubmitter": false,
  "isEdited": false,
  "createdAt": "2026-06-02T14:30:00.000Z",
  "permalink": "https://www.reddit.com/r/technology/comments/1abcd2e/some_thread/abc123/",
  "awardsCount": 0,
  "numReplies": 3,
  "inputMode": "subreddit",
  "sourceInput": "r/technology",
  "source": "reddit-oauth"
}
```

### How it works

The Actor uses a managed data-source chain described by the live contract:

1. Reddit OAuth is used when owner-managed Reddit credentials are configured.
2. The primary data provider is used as a managed fallback source.
3. The fallback data provider is used as an additional managed fallback source.

The live manifest also shows `source` telemetry in the dataset, so each record can indicate which source served it. The input schema routes each query item by shape when `mode` is set to `auto`, and `includeReplies` and `maxDepth` shape how deeply thread replies are traversed. The dataset schema exposes the comment table view with `author`, `body`, `score`, `subreddit`, `postTitle`, `createdAt`, and `permalink`.

### Pricing

#### Startup billing and empty runs

The `apify-actor-start` event costs **$0.00005 per startup unit**. Apify charges one startup unit per GB of allocated memory, with a minimum of one unit, so a 2 GB run incurs two units. This startup charge still applies when input is invalid, no results are found, or an upstream request fails. Statements about free, unbilled, or skipped results refer only to the corresponding result event; they do not waive the startup charge. Apify platform usage is included in the event prices and is not passed through as an additional customer charge. Check the live [Pricing tab](https://apify.com/khadinakbar/reddit-comments-scraper/pricing) for current events, tiers, and rates. Result limits cap result events, not the entire run cost.

This Actor uses Pay per event pricing with Apify platform usage included. The primary event is `Comment scraped`, and the live Pricing tab shows the current per-event and platform usage details.

For example, a run that returns one hundred comments is billed as one hundred comment events, with platform usage included. The final cost depends on the live Pricing tab and the amount of output produced by the Actor.

### Use with AI agents (MCP)

This Actor is available as an Apify Actor usable through Apify MCP. It accepts a Reddit reference and returns structured comment JSON that can be fed into downstream agent steps such as summarization, topic extraction, moderation review, or field-level filtering.

Actor identity: `khadinakbar/reddit-comments-scraper`

Tool description: use this Actor when an agent needs comment-level Reddit data from a thread URL, subreddit, user profile, or keyword, with one dataset item per comment and source metadata included in each record.

> Scrape the comments from this Reddit thread and return concise JSON for downstream analysis. Use the thread URL, keep nested replies enabled, and cap the result to 30 comments.

Output interpretation: the dataset contains one record per comment. `body` is the comment text, `author` is the account name, `score` shows the Reddit score, `depth` shows reply nesting, `parentId` connects reply chains, and `permalink` points to the source comment.

Provenance: each record includes `sourceInput`, `inputMode`, and `source` so an agent can track which input produced the item and which managed source served it.

Scope and pagination: `maxComments` is the hard cap for the run, and the Actor stops once that cap is reached. For thread inputs, `includeReplies` and `maxDepth` shape how far reply trees are expanded. For subreddit and user inputs, the returned feed is flat by nature.

Cost guidance: because billing is tied to returned comments, keeping `maxComments` aligned with the agent task size helps keep the payload and billed events aligned.

### Apify API example

JavaScript:

```javascript
const { ApifyClient } = require("apify-client");

(async () => {
  const client = new ApifyClient({
    token: process.env.APIFY_TOKEN,
  });

  const run = await client.actor("khadinakbar/reddit-comments-scraper").call({
    queries: ["r/technology"],
    mode: "auto",
    maxComments: 10,
    responseFormat: "concise",
  });

  const { items } = await client.dataset(run.defaultDatasetId).listItems({
    clean: true,
  });

  console.log(items);
})();
```

Set `APIFY_TOKEN` in your environment before running the example.

### Best results and outcome guidance

- Use a thread URL when you need full reply context around a specific discussion.
- Use `auto` mode for mixed input lists, since the Actor detects thread, subreddit, user, and keyword patterns per item.
- Use `concise` when the next step is an AI model or a lightweight pipeline.
- Use `detailed` when you need comment metadata such as HTML body, flair, controversiality, or stickied status.
- Keep `maxComments` aligned with the amount of comment coverage you need.
- Use `includeReplies` and `maxDepth` to shape how deep the thread traversal should go.

### Focused standalone workflow

This Actor is designed as a focused standalone workflow.

### Design note

I found that the dataset contract is centered on a single comment record schema, with `author`, `body`, `score`, `subreddit`, `postTitle`, `createdAt`, and `permalink` highlighted in the overview table view.

### FAQ

#### Can I mix thread URLs, subreddits, users, and keywords in one run?

Yes. The `queries` array accepts mixed input types, and `auto` mode routes each item by shape.

#### What does one output record represent?

One output record represents one scraped Reddit comment.

#### When should I use `thread` instead of `auto`?

Use `thread` when you want every input item treated as a post URL, especially in workflows where the source format is already known.

#### When should I use `search`?

Use `search` when a keyword input should be routed as search text rather than interpreted as a subreddit or another source shape.

#### What fields help me rebuild comment context?

`commentId`, `parentId`, `postId`, `depth`, `threadRelation`, and `permalink` are the main fields for reconstructing context.

### Responsible use

This Actor collects public Reddit comments for analysis, research, and workflow automation. Use the data in ways that respect Reddit source availability, applicable law, and the rights and expectations of the people who wrote the comments. For workflows that involve personal data handling, keep your use aligned with your own compliance requirements and data-governance practices.

# Changelog

This Actor's version history is a separate document: https://apify.com/khadinakbar/reddit-comments-scraper/changelog.md

# Actor input Schema

## `queries` (type: `array`):

List of Reddit inputs to scrape comments from. Each item is auto-detected as one of: a thread/post URL (e.g. 'https://www.reddit.com/r/technology/comments/abc123/title/'), a subreddit ('r/technology' or just 'technology'), a user profile ('u/spez' or a full /user/ URL), or a free-text keyword to search ('best mechanical keyboard'). Mixing types in one run is fine. This is NOT for post bodies only — the output unit is always a comment; for post-level subreddit analytics use the reddit-posts-comments-scraper actor.

## `mode` (type: `string`):

How to interpret each item in 'queries'. Leave as 'auto' (default) to detect thread/subreddit/user/keyword per item from its shape. Force a single mode only when auto-detection mis-reads your inputs (e.g. force 'search' to treat a one-word input as a keyword instead of a subreddit). Does NOT change the output shape, only how inputs are routed.

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

Maximum number of comments to return across all inputs in this run. The actor stops and billing stops once this cap is reached (you are charged per comment returned). Defaults to 200. Raise it for full-thread or full-subreddit pulls; one viral thread can hold tens of thousands of comments.

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

Order in which Reddit returns comments within a thread: 'top' (highest score first, default), 'best' (Reddit confidence ranking), 'new', 'controversial', 'old', or 'qa'. For subreddit and user inputs Reddit always returns newest-first regardless of this value. Affects which comments you get first when 'maxComments' is smaller than the full thread.

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

When true (default), the actor walks the full reply tree and expands collapsed 'load more comments' / 'continue this thread' stubs to capture deep replies, not just top-level comments. When false, only comments visible in the first response are returned (faster, cheaper, shallower). Only affects thread and keyword-search inputs; subreddit and user feeds are flat by nature.

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

How many reply levels deep to traverse in a thread, where 0 is a top-level comment, 1 is a direct reply, and so on. Defaults to 10. Lower it to cap cost on deeply nested threads; raise it to capture very long back-and-forth chains. Ignored when 'includeReplies' is false or for flat subreddit/user feeds.

## `responseFormat` (type: `string`):

'concise' (default) returns the core comment fields, kept compact for LLM/agent consumption. 'detailed' adds body HTML, author flair, controversiality, gildings, and stickied/distinguished flags. Use 'concise' for sentiment/NLP pipelines and AI agents; use 'detailed' for forensic or moderation analysis. Does not change the number of comments billed.

## `filterCommentsByKeyword` (type: `boolean`):

Only relevant for keyword inputs. When true, the actor returns only comments whose text contains your keyword, instead of every comment on the matched threads. When false (default), it returns all comments on threads that matched your keyword. Has no effect on thread, subreddit, or user inputs.

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

Proxy settings. Defaults to Apify Residential proxies, which are required because Reddit blocks datacenter IPs and rate-limits per IP. Leave as default unless you have a specific reason to override. Datacenter proxies will be blocked by Reddit.

## `redditClientId` (type: `string`):

Optional. Your own Reddit app client ID. Leave blank to use the actor owner-managed Reddit access (recommended; end users and AI agents need nothing). To self-supply, create a free app of type "web app" at https://www.reddit.com/prefs/apps. This is the app ID shown under the app name, NOT your Reddit username.

## `redditClientSecret` (type: `string`):

Optional. The secret paired with your Reddit client ID. Leave blank to use the owner-managed access. Found beside "secret" under your app at reddit.com/prefs/apps. This is NOT your Reddit account password.

## Actor input object example

```json
{
  "queries": [
    "https://www.reddit.com/r/technology/comments/1abcd2e/some_thread/",
    "u/spez",
    "r/MachineLearning",
    "ChatGPT alternatives"
  ],
  "mode": "auto",
  "maxComments": 1,
  "sort": "top",
  "includeReplies": true,
  "maxDepth": 10,
  "responseFormat": "concise",
  "filterCommentsByKeyword": false,
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

Structured records saved by this actor.

## `summary` (type: `string`):

Run summary and diagnostic metadata.

# 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 = {
    "queries": [
        "r/technology"
    ],
    "maxComments": 1,
    "proxy": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/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 = {
    "queries": ["r/technology"],
    "maxComments": 1,
    "proxy": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/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 '{
  "queries": [
    "r/technology"
  ],
  "maxComments": 1,
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call khadinakbar/reddit-comments-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,khadinakbar/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/6FNmYIpsqpZPQYRol/builds/aShSykKePc2ridQ1W/openapi.json
