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

Search public Reddit comments by keyword with clean, structured records for social listening and research.

- **URL**: https://apify.com/khadinakbar/reddit-comments-search-scraper.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** Social media, Developer tools, AI
- **Stats:** 2 total users, 1 monthly users, 50.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 comment founds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Reddit Comments Search Scraper

Reddit Comments Search Scraper finds public Reddit comments by keyword and returns one structured record per comment. It is a good fit for social listening, product research, and discussion discovery when you want clean fields such as comment text, author, subreddit, post title, score, timestamps, and source. The output is one record per matched comment, so each item represents a single public comment that matched one of your search phrases.

### Best fit and connected workflows

Use this Actor when your starting point is a keyword or phrase and your goal is to discover public Reddit comments around that topic. It works well for:

- social listening on product names, features, or category language
- research on how people discuss a topic across Reddit
- discovery workflows that start broad and then narrow to selected comments
- AI agent pipelines that need structured public comment data for summarization, clustering, or review

For connected workflows, the returned public comment URLs and post identifiers can move into downstream Reddit enrichment Actors when you need more context around selected records. Verified downstream options:

- Then use [Reddit Comments Scraper](https://apify.com/khadinakbar/reddit-comments-scraper) for engagement data after you identify relevant public comment URLs or IDs.
- Then use [Reddit Posts, Comments & Subreddit Analytics Scraper](https://apify.com/khadinakbar/reddit-posts-comments-scraper) for broader Reddit engagement and analytics after discovery.

### Practical scenario

Maya, a product researcher, starts with the phrase "AI coding assistant" and a target community such as `MachineLearning`. She runs the Actor with `sort` set to `new`, `time` set to `month`, and `responseFormat` set to `concise`. The dataset returns records with `body`, `author`, `subreddit`, `postTitle`, `commentUrl`, `score`, `createdAt`, `searchQuery`, and `source`. Maya reviews the comment text and score, selects the comments that mention evaluation workflows, and sends those comment URLs to a downstream enrichment Actor for follow-up analysis.

### Inputs

| Input | Purpose |
| --- | --- |
| `queries` | One or more public comment search phrases, with up to 20 distinct phrases. |
| `subreddit` | One public subreddit to focus the search, such as `MachineLearning`. |
| `maxComments` | Maximum unique comments stored across all queries, from 1 to 1,000. |
| `sort` | Reddit ordering for matching comments: `relevance`, `new`, `top`, or `comments`. |
| `time` | Reddit search window: `hour`, `day`, `week`, `month`, `year`, or `all`. |
| `includeNsfw` | Keeps public results explicitly marked NSFW when that fits the research task. |
| `responseFormat` | `concise` for core fields or `detailed` for moderation and award metadata. |

#### Example input

```json
{
  "queries": ["AI coding assistant", "LLM evaluation"],
  "subreddit": "MachineLearning",
  "maxComments": 100,
  "sort": "new",
  "time": "month",
  "includeNsfw": false,
  "responseFormat": "concise"
}
```

### Output fields

| Field | Meaning |
| --- | --- |
| `recordType` | Always `comment` for this focused Actor. |
| `commentId` | Reddit comment identifier, usually with the `t1_` prefix. |
| `commentUrl` | Canonical public Reddit URL for the comment. |
| `body` | Plain-text public comment body when available. |
| `author` | Reddit author name without `u/`, or null for deleted authors. |
| `authorUrl` | Canonical public Reddit profile URL when available. |
| `subreddit` | Canonical public community label with the `r/` prefix. |
| `subredditUrl` | Canonical public community URL. |
| `postId` | Reddit post identifier that contains the comment. |
| `postTitle` | Containing post title when Reddit returns it. |
| `postUrl` | Canonical public URL for the containing post when available. |
| `parentId` | Parent comment or post identifier when Reddit returns it. |
| `score` | Reddit score at retrieval time. |
| `awardsCount` | Total awards Reddit reports for the comment. |
| `createdAt` | ISO-8601 creation time when Reddit returns it. |
| `editedAt` | ISO-8601 edit time when Reddit returns it. |
| `isNsfw` | Whether Reddit explicitly marks the result as adult content. |
| `isStickied` | Whether Reddit marks the comment as stickied. |
| `searchQuery` | Input phrase that matched the comment. |
| `source` | Retrieval route: `reddit-oauth`, `reddit-public-json`, or the `sociavault` fallback. |
| `scrapedAt` | ISO-8601 normalization time. |
| `distinguished` | Reddit moderation distinction in detailed mode. |
| `controversiality` | Reddit controversiality flag in detailed mode. |

#### Example output record

```json
{
  "recordType": "comment",
  "commentId": "t1_abc123",
  "commentUrl": "https://www.reddit.com/r/MachineLearning/comments/postid/commentid/",
  "body": "I have been using the model as a coding assistant for evaluation tasks.",
  "author": "example_user",
  "authorUrl": "https://www.reddit.com/user/example_user/",
  "subreddit": "r/MachineLearning",
  "subredditUrl": "https://www.reddit.com/r/MachineLearning/",
  "postId": "postid",
  "postTitle": "Thoughts on AI coding assistants",
  "postUrl": "https://www.reddit.com/r/MachineLearning/comments/postid/thoughts_on_ai_coding_assistants/",
  "parentId": "t1_parent123",
  "score": 42,
  "awardsCount": 1,
  "createdAt": "2024-01-10T12:34:56Z",
  "editedAt": null,
  "isNsfw": false,
  "isStickied": false,
  "searchQuery": "AI coding assistant",
  "source": "reddit-oauth",
  "scrapedAt": "2024-01-10T12:40:00Z",
  "distinguished": null,
  "controversiality": null
}
```

### How it works

This Actor searches public Reddit comments by the phrases in `queries` and stores clean one-row-per-comment records in the default dataset. It supports one optional subreddit filter, Reddit ordering and time-window controls, a maximum unique comment ceiling, and a choice between concise and detailed response formats. It tries Reddit OAuth and public JSON first. If those routes return no comments, an owner-funded SociaVault fallback discovers relevant public posts, retrieves their public comments, and keeps only comments whose body contains the requested phrase. The live manifest provides the owner-managed credentials for these routes.

### Pricing

Reddit Comments Search Scraper uses Pay per event pricing plus Apify platform usage. The live pricing tab is the source of truth for current billing details.

Event-based charging uses two recorded events:

- Actor start: charged once when a run starts.
- Comment found: charged once for each validated public Reddit comment stored in the dataset.

For a simple example, a run that stores one hundred comments would create one actor-start event and one hundred comment-found events. `maxComments` also acts as the ceiling for comment-event charges. Apify platform usage is billed separately from event charges.

### Use with AI agents (MCP)

This Actor is usable through Apify MCP as a tool for searching public Reddit comments by keyword and returning structured records for agent workflows.

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

Tool description: search public Reddit comments by keyword, optionally narrow to one subreddit and a time window, and return comment-level records with text, authorship, scores, links, and metadata for downstream reasoning.

> Search public Reddit comments for "AI coding assistant" in r/MachineLearning, keep the newest matches from the past month, return concise records, and give me the dataset items plus a short summary of the most relevant comment URLs.

Output interpretation:

- `comments` points to the dataset items for row-level comment records.
- `output` points to the run outcome record in the key-value store.
- `runSummary` points to the run summary record in the key-value store.

Provenance:

- Each dataset row includes the matched query in `searchQuery`.
- `commentUrl`, `subredditUrl`, and optional `postUrl` preserve public Reddit references.
- `source` shows whether the record came from `reddit-oauth`, `reddit-public-json`, or the `sociavault` fallback.

Scope:

- The Actor searches public comments returned by Reddit search.
- It returns one record per comment and focuses on comment-level discovery rather than full-thread extraction.

Pagination and cost guidance:

- `maxComments` sets the maximum number of unique stored comments across all queries.
- Each stored comment corresponds to a `Comment found` event.
- The live Pricing tab remains the suitable place to review current billing details.

### Apify API example

```javascript
import { ApifyClient } from 'apify-client';

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

const input = {
  queries: ['AI coding assistant'],
  subreddit: 'MachineLearning',
  maxComments: 20,
  sort: 'new',
  time: 'month',
  includeNsfw: false,
  responseFormat: 'concise',
};

const run = await client.actor('khadinakbar/reddit-comments-search-scraper').call(input);

const { items } = await client.dataset(run.defaultDatasetId).listItems();

console.log('First items:', items.slice(0, 3));
```

### Best results and outcome guidance

Start with a short list of focused phrases, then narrow with `subreddit` when you already know the community. Use `new` for recent discussion, `top` for highly scored matches, and `relevance` for a broader search view. If the agent context needs to stay compact, choose `concise`; if you want moderation and award metadata, choose `detailed`. Keep `maxComments` aligned with the number of records you actually need, since it defines the storage ceiling and the comment-event ceiling.

### Design note

I found that the dataset contract always includes `recordType`, `commentId`, `commentUrl`, `subreddit`, `subredditUrl`, `isNsfw`, `isStickied`, `searchQuery`, `source`, and `scrapedAt` in every record. That made it straightforward to describe the one-record meaning and the minimum reliable output shape.

### FAQ

#### When should I use this Actor instead of a Reddit post scraper?

Use this Actor when your starting point is a keyword or phrase and you want public comment matches. If your workflow starts from a specific post or later needs broader post-level analytics, a downstream Reddit posts or comments scraper can fit the next step.

#### Can I limit results to one community?

Yes. Set `subreddit` to a single public community name such as `MachineLearning` or `r/MachineLearning`.

#### What if I want recent discussion only?

Set `time` to `hour`, `day`, `week`, `month`, or `year`, and pair it with `sort: "new"` for a recent-match view.

#### How do I get richer metadata?

Use `responseFormat: "detailed"` to include the moderation and controversiality fields that Reddit exposes in the dataset contract.

#### How do I connect this with another Reddit Actor?

A natural next step is to pass selected `commentUrl` or comment IDs into a verified downstream Actor such as [Reddit Comments Scraper](https://apify.com/khadinakbar/reddit-comments-scraper) or [Reddit Posts, Comments & Subreddit Analytics Scraper](https://apify.com/khadinakbar/reddit-posts-comments-scraper).

### Responsible use

Use public Reddit comment data for lawful research, analysis, and automation that aligns with Reddit's rules and applicable data-protection requirements. Keep collection focused on the comments you need, respect public context, and review any downstream use of the records before sharing or publishing them.

# Actor input Schema

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

Use this when you need to find public Reddit comments containing one or more phrases. Pass phrases such as "AI coding assistant" or "best standing desk". Defaults to "artificial intelligence" and accepts at most 20 distinct phrases. This is not a Reddit URL, username, or full-thread request.

## `subreddit` (type: `string`):

Use this to search comments within one public subreddit. Pass a name such as "MachineLearning" or "r/MachineLearning". Defaults to all of Reddit and accepts only one community name. This is not a subreddit URL or a list of communities.

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

Use this to cap unique comments saved across every query. Pass an integer such as 100. Defaults to 100 and accepts 1 through 1000, which also caps comment-event charges. This is not a number of comments per post or a request to retrieve a full thread.

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

Use this to choose Reddit's ordering for matching comments. Choose relevance, new, top, or comments; for example, "new" prioritizes recent matches. Defaults to relevance. This does not analyze sentiment or change Reddit's search match logic.

## `time` (type: `string`):

Use this to restrict comment search to a Reddit time window. Choose hour, day, week, month, year, or all; for example, "month". Defaults to all. This is not an exact date-range filter and Reddit may cap deep search pagination.

## `includeNsfw` (type: `boolean`):

Use this only when adult-marked public Reddit content is appropriate for the research task. Pass true to retain a result explicitly marked NSFW. Defaults to false. This does not bypass Reddit safety controls or access private communities.

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

Use this to balance agent context size against diagnostic metadata. Choose concise for core text, authorship, score, and links, or detailed for moderation and award fields; for example, "concise". Defaults to concise. This does not alter matching, pagination, or comment-event billing.

## Actor input object example

```json
{
  "queries": [
    "AI coding assistant",
    "LLM evaluation"
  ],
  "subreddit": "MachineLearning",
  "maxComments": 100,
  "sort": "new",
  "time": "month",
  "includeNsfw": false,
  "responseFormat": "concise"
}
```

# Actor output Schema

## `comments` (type: `string`):

No description

## `output` (type: `string`):

No description

## `runSummary` (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 = {
    "queries": [
        "gym"
    ],
    "subreddit": "Fitness",
    "maxComments": 1,
    "sort": "relevance",
    "time": "all",
    "includeNsfw": false,
    "responseFormat": "concise"
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/reddit-comments-search-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": ["gym"],
    "subreddit": "Fitness",
    "maxComments": 1,
    "sort": "relevance",
    "time": "all",
    "includeNsfw": False,
    "responseFormat": "concise",
}

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/reddit-comments-search-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 '{
  "queries": [
    "gym"
  ],
  "subreddit": "Fitness",
  "maxComments": 1,
  "sort": "relevance",
  "time": "all",
  "includeNsfw": false,
  "responseFormat": "concise"
}' |
apify call khadinakbar/reddit-comments-search-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/LBOeAB0frqbihEMl0/builds/WUptRIn2iD8gMaypc/openapi.json
