# YouTube Comment Keyword Search (`unknownbrain/youtube-comment-keyword-search`) Actor

Find words and phrases in YouTube comments and replies. Search entire comment sections with any/all matching, case and whole-word controls, and date filters. Export complete matching comments with dates, likes, authors, and thread details.

- **URL**: https://apify.com/unknownbrain/youtube-comment-keyword-search.md
- **Developed by:** [ABHIJEET S](https://apify.com/unknownbrain) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.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.

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

## YouTube Comment Keyword Search

Find words and phrases in YouTube comments and replies, and export the full matching entries for audience research, feedback analysis, brand monitoring, or finding specific questions.

### Features

- Search all available comments and replies on one or more videos by default.
- Enter several words or phrases and match any term or all terms within the same comment.
- Search top-level comments, replies, or both. Matching replies are returned even when their parents do not match.
- Case-insensitive matching by default, with optional case-sensitive matching.
- Whole-word matching by default: `cat` does not match `category`. Turn it off for matches inside longer words.
- Match complete phrases, allowing differences in whitespace. Each result preserves the original full comment body.
- Choose Newest first or Top comments, and optionally filter by publication date or age.
- Export matching comments as JSON or CSV, with the matched terms, publication and update dates, likes, author name, video information, and thread relationships.
- Separate video summaries show comments checked, matches found, completion status, elapsed time, and warnings.

### How to use

1. Add one or more video URLs.
2. Enter the words or phrases you want to find, one term per entry.
3. Choose Any term or All terms, and whether to search comments, replies, or both.
4. Start the run and export the matching results.

For example, search for `bad quality`, `refund`, and `not working` in **Any term** mode to find entries mentioning at least one of those phrases. In **All terms** mode, every entered term must appear in the same comment or reply; terms are never combined across different entries.

```json
{
  "videos": [{"url": "https://www.youtube.com/watch?v=MrmPDUvKyLs"}],
  "searchTerms": ["love", "favorite song"],
  "matchMode": "any",
  "searchIn": "both",
  "caseSensitive": false,
  "wholeWords": true,
  "sort": "newest"
}
```

### Limits and completion

There is no comment scan limit by default. An optional `maxCommentsToCheck` for each video limits the combined number of top-level comments and replies checked. This is a scan limit, not a target number of matching results. For replies-only searches, parent comments are also checked to locate their replies, but only matching replies appear in the dataset.

The default processing timeout is **3,600 seconds per video**. Very large comment sections may need more time. Saved matches survive interruptions. A timeout or incomplete extraction is reported as a **partial** scan; a `no_matches` result does not imply the entire section was checked unless `scanCompleted` is true. Optional limits are explicitly reported in the summary.

Literal text matching finds the words and phrases you enter. Synonyms, sentiment, and meaning-based matching are not inferred. Whole-word boundaries use Unicode word characters. Publication dates may be estimated when exact dates are unavailable, and that precision is included in each result.

Date filters use UTC calendar days: `1 day` means today, and `2 days` means yesterday plus today. Entering a date or age switches sorting to Newest first. With this filter, replies are searched within qualifying parent threads.

### Output

Every dataset row contains the **complete matching comment or reply**, plus:

- `matchedTerms`, `matchedTermCount`, and `matchMode`.
- Comment ID and direct link, publication and update timestamps, and like count.
- Author display name and creator reply indicator when established.
- Reply indicator, parent ID, root thread ID, and relationship type.
- Video ID, URL, title, and owner channel ID.
- Collection timestamp, sort, and publication date precision.

Matching replies can reference a parent that is absent from the dataset because it did not match. Root comments include the available total reply count. The collected reply count is unavailable in this search output and remains `null`; per-video summaries report the number of replies checked and matched. Other unavailable values are also `null`.

### Defaults

| Setting | Default |
| --- | --- |
| Comments checked per video | All available |
| Search targets | Comments and replies |
| Match mode | Any term |
| Case-sensitive | Off |
| Whole words | On |
| Sorting | Newest first |
| Simultaneous videos | 3 |
| Processing timeout per video | 3,600 seconds |

# Actor input Schema

## `videos` (type: `array`):

By default, check all available comments and replies. Optionally set a scan limit for a video; limits count parents and replies together.

## `searchTerms` (type: `array`):

Enter each word or phrase separately. A phrase must appear together in the same comment. Matching entries retain their full text.

## `matchMode` (type: `string`):

Any: return comments containing at least one term. All: every term must appear in the same comment or reply.

## `searchIn` (type: `string`):

A matching reply is returned even when its parent does not match.

## `caseSensitive` (type: `boolean`):

Off: LOVE and love match the same term.

## `wholeWords` (type: `boolean`):

On: cat does not match category. Turn off to find text inside longer words. Phrases are matched literally, allowing whitespace variations.

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

Search in Newest first or Top comments order. Publication date filtering automatically selects Newest first.

## `publishedAfter` (type: `string`):

Optional inclusive publication date: YYYY-MM-DD, 1 day (today), or 2 days (yesterday and today). Uses UTC days and selects Newest first. Replies are checked within qualifying parent threads. Leave empty to search all dates.

## `enableFallback` (type: `boolean`):

Verify unexpected empty comment sections. Failed verification is reported explicitly.

## `maxConcurrency` (type: `integer`):

Search up to this many videos simultaneously. Default: 3.

## `videoTimeoutSeconds` (type: `integer`):

Active processing timeout per video. Large comment sections may need more time. Timeouts are reported as partial scans; matching entries already saved are retained.

## Actor input object example

```json
{
  "videos": [
    {
      "url": "https://www.youtube.com/watch?v=L2udL0v3hkg",
      "maxCommentsToCheck": 100
    }
  ],
  "searchTerms": [
    "love",
    "song",
    "beautiful"
  ],
  "matchMode": "any",
  "searchIn": "both",
  "caseSensitive": false,
  "wholeWords": true,
  "sort": "newest",
  "enableFallback": true,
  "maxConcurrency": 3,
  "videoTimeoutSeconds": 3600
}
```

# Actor output Schema

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

Full matching comments and replies. Export JSON or CSV from the dataset.

## `summaries` (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 = {
    "videos": [
        {
            "url": "https://www.youtube.com/watch?v=L2udL0v3hkg",
            "maxCommentsToCheck": 100
        }
    ],
    "searchTerms": [
        "love",
        "song",
        "beautiful"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("unknownbrain/youtube-comment-keyword-search").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 = {
    "videos": [{
            "url": "https://www.youtube.com/watch?v=L2udL0v3hkg",
            "maxCommentsToCheck": 100,
        }],
    "searchTerms": [
        "love",
        "song",
        "beautiful",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("unknownbrain/youtube-comment-keyword-search").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 '{
  "videos": [
    {
      "url": "https://www.youtube.com/watch?v=L2udL0v3hkg",
      "maxCommentsToCheck": 100
    }
  ],
  "searchTerms": [
    "love",
    "song",
    "beautiful"
  ]
}' |
apify call unknownbrain/youtube-comment-keyword-search --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,unknownbrain/youtube-comment-keyword-search"
        }
    }
}
```

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/Ddk1vfytDpLKXoDSl/builds/WDhfzar8rUC33PhYr/openapi.json
