# Youtube Comment Scrapper (`deeper/youtube-comment-scrapper`) Actor

Scrape comments on Youtube Video Pages. Just specify the video page urls to visit and how many comments you would like to collect.
We'll get all meaningful information: comment text, author, publication date, number of likes and replies and video+channel url and id

- **URL**: https://apify.com/deeper/youtube-comment-scrapper.md
- **Developed by:** [Deeper Scrapper](https://apify.com/deeper) (community)
- **Categories:** Social media, Videos
- **Stats:** 714 total users, 10 monthly users, 62.8% runs succeeded, 22 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $2.20 / 1,000 video details

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Channel/Video/Comment Scrapper

A simple youtube scrapper that either

- collect channel information and video details for the first 30 videos.
- collect most recent shorts for a channel
- collect video details and comments from a list of youtube video URLs.

If you provide a channel url in input, we will collect channel information and up to 30 most recent videos for that channel, and possibly collect details information and comments for each of these.
If you provide a video url in input, we will collect video information and possibly comments but we could miss some channel information.

The "details" parameter should be used if you want to collect details information about all video found on the channel.
The "max\_comments" parameter allows you to specify how many comments you want to collect for each video URL.  Note that this number is indicative as comments are collected by page (of 20 comments in general).
If comments are collected, you will pay per video+comments collected otherwise it's just based on the number of video collected

### FAQ

#### What data are collected ?

###### For the channel

```
{
  "channel_id": "UC4f0qvPJLqGTuLyy2iHOd-g",
  "channel_url": "https://www.youtube.com/@rtbf_info/",
  "channel_shortname": "rtbf_info",
  "channel_name": "RTBF Info",
  "channel_description": "Cette chaîne vous propose les actualités quotidiennes les plus importantes de la rédaction info de la RTBF. Vous les trouverez sous forme d'extraits du JT, de shorts, de lives, et de contenus exclusifs.\n\nLa RTBF (Radio Télévision Belge Francophone) produit, édite et diffuse des programmes à l’attention de tous les publics dans leurs diversités. Elle propose de multiples offres audiovisuelles dans les médias (Radio, TV, Internet et Réseaux sociaux).",
  "channel_thumbnail": "https://yt3.googleusercontent.com/JjwCgdIt3BCKiq-AaTCpdmhwa3a01ejjJC8K6xcjoTSZnUxiTE9t5Z2jupkr4a1cwHCgPAtYAw=s900-c-k-c0x00ffffff-no-rj",
  "channel_joined_date": "2022-10-14T00:00:00",
  "channel_location": "Belgium",
  "channel_videos": 2223,
  "channel_views": 46933391,
  "channel_subscribers": 193000,
}
```

###### For the video

```
{
  "video_idx": 1,
  "video_id": "xpg_PujFT7s",
  "video_is_short": False,
  "video_thumbnail": "https://i.ytimg.com/vi/xpg_PujFT7s/hqdefault_8866.jpg?sqp=-oaymwEjCNACELwBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLAGS4syUXTIGh57ZRQla0Xlawim-A",
  "video_title": "Donald Trump devient officiellement le 47ème président des Etats-Unis - RTBF Info",
  "video_url": "https://www.youtube.com/watch?v=xpg_PujFT7s",
  "video_text": "Donald Trump a prêté serment en tant que 47e président des États-Unis lundi peu après 12h00 locales (18h00 heure belge) dans la Capitol. Il devient ainsi le deuxième président états-unien de l’histoire à effectuer deux mandats non consécutifs.\n\n0:00 Introduction\n0:17 Donald Trump est le 47ème président des États-Unis \n2:50 20.000 personnes dans une salle omnisports\n3:22 Le froid n'a pas dissuadé ses partisans \n7:47 Les suprémacistes de l'extrême droite en évidence\n8:44 Quel impact économique?\n\nUn sujet diffusé le 20/01/25\n\n-----------------------------------------------------------------------------------------------------------------------\n\n📌 Retrouvez l'info de la RTBF\n\nSur Auvio ► https://www.rtbf.be/auvio/emissions/d...\n\nSur le site RTBF info ► https://www.rtbf.be/info/\n\nSur Facebook ►   / rtbfinfo  \n\nSur Instagram ►   / rtbfinfo  \n\n-----------------------------------------------------------------------------------------------------------------------\n\n© RTBF \n\n#trump #usa #rtbf #rtbfinfo #trumpnews #trumpupdate #musk",
  "video_relative_date": "2 days ago",
  "video_duration": "11:51",
  "video_views": 27428,
  "video_comments": 134,
  "video_likes": 336,
  "video_date": "2025-01-21T09:00:00",
}
```

###### For the captions

```
{
  "caption_languageCode": "fr",
  "caption_languageName": "French (auto-generated)",
  "caption_data": [...All the text segments...]
}
```

###### For the comment

```
{
  "comment_idx": 1,
  "comment_id": "UgwGmC_S-wtGvMiMxa54AaABAg",
  "comment_url": "https://www.youtube.com/watch?v=xpg_PujFT7s&lc=UgwGmC_S-wtGvMiMxa54AaABAg",
  "comment_author_name": "jeanrenaissance309",
  "comment_author_channel": "UCljlLgqDA5fHLn2EoQwHnZg",
  "comment_author_thumbnail": "https://yt3.ggpht.com/ytc/AIdro_ltG5Vixvi3d0Yh00mrIlUB2on93_zWY8hkMojmBpX9mvBiNJjt4vNgL5Rn8XCPf9bnFg=s88-c-k-c0x00ffffff-no-rj",
  "comment_relative_date": "1 day ago",
  "comment_date": "~2025-01-23T09:00:00+00:00",
  "comment_text": "Vive Trump !!\nLe ménage va commencer.",
  "comment_likes": 6,
  "comment_replies": 0
}
```

#### How does date filtering work ?

You can use "dateFilter" (since) and "dateFilterTill" (till) to collect only videos published within a date range. When a video's publication date cannot be extracted (e.g. for shorts), the video always passes the date filters and is included in the results.

#### Can we get more than 30 videos per channel ?

Yes, use the "max\_videos" parameter to specify how many videos you want to collect. The scraper will paginate through the channel's video listing to fetch beyond the initial 30.

#### Can we get the video captions ?

Yes, simply activate the "scrap\_captions" parameter

#### Can we get the video captions only in specific language ?

Yes, use the "caption\_languages" paramter to pass the language code you are interested in

#### Can we get the comments count ?

Can I get the commentCount on the video without scrapping the comments themselves ?  Unfortunately, no, you can't.
We need to collect the comments to get the count information.

#### Why am I not getting the replies to the comments ?

Currently, only the first level comments is being collected, if you are interested by replies to comment, let us know and we'll adapt the scrapper

#### How does pricing work ?

This actor uses the **pay-per-event** pricing model. You are charged based on the operations performed:

| Event | Price (USD) | Description |
|-------|-------------|-------------|
| Actor start | $0.005 | One-time charge per run (charged automatically by the platform) |
| Video page | $0.005 | Loading a channel's videos or shorts tab (~30 videos) |
| Video detail | $0.0025 | Fetching detailed data for a single video |
| Video comment | $0.002 | Each comment collected |
| Video caption | $0.0025 | Each caption language collected for a video |
| Extra compute time | $0.001 | Small charge to cover platform compute costs when needed |

**Example costs:**

| Scenario | Results | Old price (pay-per-result) | New price (pay-per-event) |
|----------|--------:|---------------------------:|--------------------------:|
| Channel with 30 videos (details, no comments) | 30 | $0.075 | ~$0.09 |
| Channel with 30 videos + 20 comments each | 630 | $1.575 | ~$1.29 |
| Single video with 200 comments | 201 | $0.5025 | ~$0.41 |
| Channel with 10 videos + captions (2 languages) | 30 | $0.075 | ~$0.09 |

# Actor input Schema

## `start_urls` (type: `array`):

URLs to start with.  It could be either a channel url (we will collect info about the top videos on the channel) or a video url

## `details` (type: `boolean`):

Scrapping details allows to get the full video description, comment counts and view counts

## `scrap_videos` (type: `boolean`):

Scrapping videos allows to get the videos from the channel

## `scrap_shorts` (type: `boolean`):

Scrapping shorts allows to get the short videos from the channel (currently, details and comments are not scrapped for shorts, so some fields will be empty like the publication date).  Filtering by date is not applied to shorts.

## `dateFilter` (type: `string`):

Select a date cutoff to collect only video more recent than this one.  In any case, the most recent video is always returned for every channel.

## `dateFilterTill` (type: `string`):

Select an upper date cutoff to collect only videos published before this date.  Combined with the 'since' date filter, this creates a date range filter.

## `max_videos` (type: `integer`):

We will scrap the details (and possibly comments) of that amount of video found on the channel.  Use low value to have run executing faster.  Use 30 to get the first page data, use more to go back in time.

## `max_comments` (type: `integer`):

Keep scrolling the page down until we've reach at least that number of comments.  This number is not strict, if we get more comments by scrolling the page, they will be returned as well.  This is applicable only if 'details' is set to True.

## `scrap_captions` (type: `boolean`):

Scrapping caption allows to get the transcript of the video (there is one extra result by caption language loaded)

## `caption_languages` (type: `array`):

List of caption languages to collect (i.e. : \['en','fr']), pass an empty array to collect all available languages

## Actor input object example

```json
{
  "start_urls": [
    {
      "url": "https://www.youtube.com/channel/UC4f0qvPJLqGTuLyy2iHOd-g"
    },
    {
      "url": "https://www.youtube.com/watch?v=3xGwtP97FXI"
    }
  ],
  "details": true,
  "scrap_videos": true,
  "scrap_shorts": true,
  "dateFilter": "",
  "dateFilterTill": "",
  "max_videos": 10,
  "max_comments": 20,
  "scrap_captions": false,
  "caption_languages": []
}
```

# Actor output Schema

## `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 = {
    "start_urls": [
        {
            "url": "https://www.youtube.com/channel/UC4f0qvPJLqGTuLyy2iHOd-g"
        },
        {
            "url": "https://www.youtube.com/watch?v=3xGwtP97FXI"
        }
    ],
    "max_videos": 10,
    "max_comments": 20,
    "caption_languages": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("deeper/youtube-comment-scrapper").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 = {
    "start_urls": [
        { "url": "https://www.youtube.com/channel/UC4f0qvPJLqGTuLyy2iHOd-g" },
        { "url": "https://www.youtube.com/watch?v=3xGwtP97FXI" },
    ],
    "max_videos": 10,
    "max_comments": 20,
    "caption_languages": [],
}

# Run the Actor and wait for it to finish
run = client.actor("deeper/youtube-comment-scrapper").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 '{
  "start_urls": [
    {
      "url": "https://www.youtube.com/channel/UC4f0qvPJLqGTuLyy2iHOd-g"
    },
    {
      "url": "https://www.youtube.com/watch?v=3xGwtP97FXI"
    }
  ],
  "max_videos": 10,
  "max_comments": 20,
  "caption_languages": []
}' |
apify call deeper/youtube-comment-scrapper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=deeper/youtube-comment-scrapper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

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