# 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
- **Features:** Limited permissions
- **Stats:** 26 total users, 5 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/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 search, channel, Shorts, and comments scraper

Choose one clear workflow: search YouTube videos or Shorts 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 or Shorts by keyword** | Topics, keywords, or phrases | All video results or Shorts only, 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 |

For Shorts-only keyword search, select **Search content type → Shorts only**.
This uses YouTube’s dedicated Shorts filter and excludes regular videos.
Channel discovery by keyword is not supported. To collect a known channel’s
Shorts, provide the channel directly and select its **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.
   For keyword search, choose **Search content type → Shorts only** to collect Shorts.
   For channels, choose **Channel tab → Shorts** instead.
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 or Shorts by keyword |
| Search queries | Topics, keywords, or phrases for video or Shorts search | OpenAI Codex tutorial |
| Search content type | All videos and Shorts, or Shorts only for keyword search | All videos and Shorts |
| 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 or Shorts 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

Search for Shorts by keyword with this input:

```json
{
  "workflow": "search",
  "searchQueries": ["home coffee brewing"],
  "searchContentType": "shorts",
  "maxVideos": 20,
  "includeComments": false
}
```

You can also 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

**$0.60 per 1,000 unique saved YouTube items**, plus **$0.01 once per run**.
A video result, top-level comment, or reply counts as one item. Rates are the same
across Apify plans and match the YouTube rate in our
[Movie Reviews & YouTube Scraper](https://apify.com/devcake/movie-reviews-scraper).

Apify platform usage and Apify Proxy traffic are included. Custom proxy providers
bill separately. There is no additional keyword fee. Duplicates within a run,
errors, and summary records have no item fee; the startup fee still applies when
a valid run finds no results. Direct comment input does not charge for the supplied
video URL itself.

For example, five video results and 100 comments cost **$0.073**, including startup.
Use the video, comment, and reply limits to control collection volume. The Actor
also respects the run's maximum charge limit and stops starting work when no item
budget remains; requests already in progress may finish. See `SUMMARY.billing`
for charged event counts and the [Pricing tab](https://apify.com/devcake/youtube-search-comments-scraper/pricing)
for the prices effective for your run.

### ⚠️ 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 YouTube video or Shorts results; it is not a complete
  archive of every video on YouTube.
- 🔎 Channel discovery by keyword is 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 videos or Shorts 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.

## `searchContentType` (type: `string`):

Choose Shorts only to collect Shorts matching your search queries, or All videos and Shorts for mixed results. Applies only to keyword search; use Channel tab for known channels.

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

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

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

Choose the Videos, Shorts, or Live tab for the channels above. Applies only to Collect a known channel; use Search content type for keyword search.

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

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

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

Set the maximum unique videos or Shorts to collect in total across all 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 or Short.

## `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"
  ],
  "searchContentType": "all",
  "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"
    ],
    "searchContentType": "all",
    "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"],
    "searchContentType": "all",
    "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"
  ],
  "searchContentType": "all",
  "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/5itq9BPyMng3XxiU9/openapi.json
