# YouTube Search & Comments Scraper (`devcake/youtube-search-comments`) Actor

Search YouTube videos and extract public comments, replies, and video metadata. Export results to CSV, Excel, or JSON.

- **URL**: https://apify.com/devcake/youtube-search-comments.md
- **Developed by:** [devcake](https://apify.com/devcake) (community)
- **Categories:** Social media, SEO tools, Videos
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 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/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

## YouTube search, channel, Shorts, and comments scraper

Choose one clear workflow: search standard YouTube video results by keyword,
collect the Videos, Shorts, or Live tab from known channels, or extract comments
from specific video URLs. Results are saved as structured Dataset rows.

[Try the YouTube Search & Comments Scraper on Apify](https://apify.com/devcake/youtube-search-comments-scraper).

### 🔎 What can you do with this YouTube scraper?

- 🔎 Search YouTube for up to 20 topics, keywords, or phrases in one run.
- 📺 Collect public videos, Shorts, or live entries from channel URLs and @handles.
- 🔗 Scrape comments directly from YouTube watch, Shorts, live, or youtu.be URLs.
- 🎬 Save up to 1,000 unique video results across all searches.
- 📋 Collect video titles, URLs, channel names, durations, publish information, and
  displayed view counts.
- 💬 Optionally collect up to 2,000 public comments per video.
- ↩️ Optionally include up to 500 public replies per comment.
- 🔗 Keep replies connected to their original comments.
- 📥 Download results in CSV, Excel, JSON, and other common formats.
- 📅 Schedule repeat runs or connect the results to other apps through Apify.

Comments and replies are turned off by default, making it easy to create a
simple YouTube search-results dataset. Turn them on only when you need them.

### Choose the right workflow

| Workflow | What you provide | What it returns |
|---|---|---|
| **Search videos by keyword** | Topics, keywords, or phrases | Standard YouTube video search results, with optional comments and replies |
| **Collect a known channel** | Channel URL, `@handle`, or channel ID | Entries from that channel's Videos, Shorts, or Live tab, with optional comments and replies |
| **Comments from video URLs** | Watch, Shorts, live, youtu.be URLs, or video IDs | Public comments and optional replies from those exact videos |

Keyword search currently targets standard video results. It does **not** search
for channels by keyword and it does **not** provide a Shorts-only keyword
filter. To collect channel Shorts, provide the channel directly and select the
**Shorts** tab.

### 👥 Who is this Actor for?

- 🎥 **Content creators** researching videos and audience reactions around a topic.
- 📣 **Marketing teams** comparing channels, content, and viewer discussions.
- 🔬 **Researchers** building datasets for text analysis or academic work.
- 🏢 **Agencies** collecting public comments for qualitative review.
- 📰 **Media teams** tracking which videos appear for selected keywords.
- 📊 **Analysts** exporting structured YouTube search and comment data.

This Actor collects source data. It does not generate sentiment scores,
summaries, transcripts, or engagement predictions.

### 🚀 How to run the Actor

1. Open the Actor's **Input** tab.
2. Choose a workflow.
3. Open the matching source section and enter search queries, channels, or video URLs.
4. Choose the maximum number of videos to process.
5. For search and channel workflows, turn on **Include comments** when needed.
6. Turn on **Include replies** to preserve public discussion threads.
7. Click **Start**, then open **Output** to review or download the Dataset.

Enabling replies also enables comments because every reply belongs to a comment
thread.

### ⚙️ Input

| Setting | What it controls | Starting value |
|---|---|---:|
| Workflow | Selects keyword search, known-channel collection, or direct comments | Search videos by keyword |
| Search queries | Topics, keywords, or phrases for standard video search | OpenAI Codex tutorial |
| Channel URLs | Known channel URLs, @handles, or channel IDs | @OpenAI example |
| Channel tab | Videos, Shorts, or live-stream entries from known channels | Videos |
| Video URLs or IDs | Exact videos or Shorts whose comments should be collected | Example video URL |
| Maximum videos | Total unique videos saved across all queries | 20 |
| Include comments | Whether public top-level comments are collected | Off |
| Maximum comments per video | Comment limit for each video | 100 |
| Include replies | Whether public replies are collected | Off |
| Maximum replies per comment | Reply limit for each top-level comment | 50 |
| Language code | YouTube interface language used for requests | en |
| Country code | Country context used to localize results | US |

Only the source section matching the selected workflow is used. For a quick
first run, keep **Search videos by keyword**, replace the example query, and
leave comments and replies turned off.

### 📦 What data does the Actor return?

Results are stored in an Apify Dataset. Depending on your choices, the Dataset
contains video rows, comment rows, and reply rows.

#### 🎬 Video results

| Data | Description |
|---|---|
| Search query | The query that found the video |
| Video title | The title shown in YouTube search |
| Video ID and URL | The video's identifier and direct link |
| Channel | The channel name shown with the result |
| Published | The publication information displayed by YouTube |
| Duration | The displayed video length |
| Views | The displayed view-count text |
| Collected at | When the result was saved |

#### 💬 Comments and replies

| Data | Description |
|---|---|
| Video ID and URL | The video connected to the comment |
| Comment ID | The unique comment or reply identifier |
| Parent comment ID | The original comment connected to a reply |
| Author | The displayed author name and channel ID |
| Text | The public comment or reply text |
| Published | The publication information displayed by YouTube |
| Likes | The displayed like count |
| Reply count | The number of replies shown for a top-level comment |
| Collected at | When the result was saved |

You can download the Dataset as CSV, Excel, JSON, JSONL, XML, HTML, or RSS from
the Apify Console.

### 🧪 Example

Suppose you want to research videos about **home coffee brewing**:

- Enter `home coffee brewing` as the search query.
- Set **Maximum videos** to 10.
- Turn on **Include comments**.
- Leave **Include replies** off.

The result will contain up to 10 matching video rows plus the requested public
comments for each video. You can then export the Dataset to Excel or CSV for
review.

### 🎯 Use cases

#### 📊 Build a YouTube search-results dataset

Search for one or more topics and export video titles, channels, links,
durations, publish information, and displayed views.

#### 📤 Export YouTube comments

Collect public comment text with author details, likes, publication information,
and the source video link. Download the results for research or review.

#### 🗣️ Study audience discussions

Include replies to preserve public conversations and the relationship between a
reply and its original comment.

#### 🔄 Compare content across keywords

Run several search queries together to see which unique videos and channels
appear for different topics.

#### 📺 Export videos from a known channel

Provide a channel URL, `@handle`, or channel ID and select its Videos, Shorts,
or Live tab. This is direct channel collection, not channel discovery by keyword.

#### 📱 Collect Shorts and Shorts comments

Select a known channel's Shorts tab to export its public Shorts. To collect
comments from exact Shorts, use the direct video-comments workflow with Shorts
URLs and optionally enable replies.

### 💵 Pricing

This Actor is free to use. Standard Apify platform usage charges may still
apply based on your Apify plan and the resources used by each run. See the
[Pricing tab](https://apify.com/devcake/youtube-search-comments-scraper/pricing)
for current details.

### ⚠️ Limitations

- 🌐 Only public information available without signing in can be collected.
- 🔒 Private, members-only, age-restricted, or otherwise unavailable content is
  not supported.
- 💬 Videos with comments turned off cannot return comments.
- 🇺🇸 Search results default to an English-language, United States context.
- 🌍 Language and country context can be changed in the Actor input.
- 🔄 Titles, view counts, comments, and rankings can change between runs.
- 📚 The Actor searches standard YouTube video results; it is not a complete
  archive of every video on YouTube.
- 🔎 Channel discovery by keyword and Shorts-only keyword search are not supported.

Please use collected data responsibly and follow applicable laws and platform
rules.

### ❓ Frequently asked questions

#### 💬 Can I scrape YouTube comments?

Yes. Enter a search query and turn on **Include comments**. The Actor will first
find matching videos and then collect the public comments available for those
videos. Comments that are disabled, private, or unavailable cannot be returned.

#### ↩️ Can I collect replies to YouTube comments?

Yes. Turn on **Include replies** and choose the maximum number of replies per
comment. Replies are saved with the ID of their original comment so the
conversation can be reconstructed after export.

#### 📥 Can I export YouTube comments to Excel or CSV?

Yes. When the run finishes, open the Dataset in the **Output** tab and select
the format you want. Apify supports Excel, CSV, JSON, and several other export
formats.

#### 🚫 Why did a video return no comments?

The video's comments may be disabled, restricted, unavailable without signing
in, or temporarily missing from the public page. Other successfully collected
videos remain available in the same Dataset.

#### 🔑 Do I need a YouTube API key?

No. Enter your search queries directly in the Actor input and start the run.

#### 📅 Can I run the same search regularly?

Yes. Apify lets you schedule Actor runs. This is useful when you want to refresh
a search-results or comments dataset on a recurring basis.

# Actor input Schema

## `workflow` (type: `string`):

Search by keyword, collect a known channel tab, or scrape comments from specific video URLs.

## `searchQueries` (type: `array`):

Enter one or more topics, keywords, or phrases.

## `channelUrls` (type: `array`):

Examples: https://www.youtube.com/@OpenAI, @OpenAI, or a UC… channel ID.

## `channelContentType` (type: `string`):

Choose whether to collect the channel's Videos, Shorts, or Live tab.

## `videoUrls` (type: `array`):

Supports watch, Shorts, live, youtu.be URLs, and 11-character video IDs.

## `maxVideos` (type: `integer`):

Maximum unique videos collected across search queries or channels. Direct-comment runs apply this cap to supplied URLs.

## `includeComments` (type: `boolean`):

Collect public top-level comments from every discovered video.

## `maxCommentsPerVideo` (type: `integer`):

Maximum number of public top-level comments collected from each video.

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

Collect public replies and connect them to their parent comments. This also enables comments.

## `maxRepliesPerComment` (type: `integer`):

Maximum public replies collected from each top-level comment.

## `languageCode` (type: `string`):

YouTube interface language, for example en, es, de, or fr.

## `countryCode` (type: `string`):

Two-letter country context, for example US, GB, DE, or BR.

## Actor input object example

```json
{
  "workflow": "search",
  "searchQueries": [
    "OpenAI Codex tutorial"
  ],
  "channelUrls": [
    "@OpenAI"
  ],
  "channelContentType": "videos",
  "videoUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "maxVideos": 20,
  "includeComments": false,
  "maxCommentsPerVideo": 100,
  "includeReplies": false,
  "maxRepliesPerComment": 50,
  "languageCode": "en",
  "countryCode": "US"
}
```

# Actor output Schema

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

No description

## `summary` (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 = {
    "workflow": "search",
    "searchQueries": [
        "OpenAI Codex tutorial"
    ],
    "channelUrls": [
        "@OpenAI"
    ],
    "videoUrls": [
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("devcake/youtube-search-comments").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 = {
    "workflow": "search",
    "searchQueries": ["OpenAI Codex tutorial"],
    "channelUrls": ["@OpenAI"],
    "videoUrls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
}

# Run the Actor and wait for it to finish
run = client.actor("devcake/youtube-search-comments").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 '{
  "workflow": "search",
  "searchQueries": [
    "OpenAI Codex tutorial"
  ],
  "channelUrls": [
    "@OpenAI"
  ],
  "videoUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ]
}' |
apify call devcake/youtube-search-comments --silent --output-dataset

```

## MCP server setup

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

```

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/mh8TXSmZRBrSQPex3/builds/b9Va3JH15PvT0QMGk/openapi.json
