# Youtube Scraper | Youtube Channel Scraper (`runtime/youtube-channel-scraper`)

YouTube Channel Scraper is an Apify Actor that scrapes video data and comments from a YouTube channel. It extracts key details such as video title, URL, view count, streaming time (in days), hashtags, description, comments count, and individual comments with user IDs.

- **URL**: https://beta-securitybyobscurity.apify.com/runtime/youtube-channel-scraper.md
- **Developed by:** [scraping automation](https://beta-securitybyobscurity.apify.com/runtime) (community)
- **Categories:** Social media, Videos, Automation
- **Stats:** 45 total users, 4 monthly users, 100.0% runs succeeded, 8 bookmarks
- **User rating**: 1.40 out of 5 stars

## Pricing

$19.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.
You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

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

# README

## Apify YouTube Scraper | YouTube Channel Scraper - Extract Video Data & Comments - Apify Actor

**The most powerful Apify YouTube scraper** that extracts comprehensive video data from YouTube channels. Perfect for content analysis, SEO research, brand monitoring, and social media analytics. Extract video metadata, comments, and engagement metrics with ease using our advanced Apify YouTube scraper.

### 🔍 Why Choose This Apify YouTube Scraper?

- ✅ **Comprehensive Video Data:** Extract titles, URLs, view counts, durations, thumbnails, and video types (normal/shorts/live)
- ✅ **Advanced Search:** Filter videos within channels using YouTube's native search
- ✅ **Smart Layout Handling:** Works with both grid and rich item layouts
- ✅ **Optimized Performance:** Efficient scrolling and resource blocking
- ✅ **Real-time Processing:** Incremental data processing and immediate dataset storage
- ✅ **Comment Analysis:** Extract and filter comments for brand safety and engagement tracking
- ✅ **SEO-Friendly Output:** Structured JSON data perfect for SEO analysis and content strategy

### 📊 Apify YouTube Scraper Use Cases

- **Content Analysis:** Track video performance and engagement metrics
- **SEO Research:** Analyze video titles, descriptions, and metadata
- **Brand Monitoring:** Track brand mentions in comments and video content
- **Competitor Analysis:** Monitor competitor channels and content strategy
- **Social Media Analytics:** Extract engagement data for social media reporting
- **Market Research:** Gather insights from video comments and viewer engagement

### 🚀 Apify YouTube Scraper Features

- ✅ **Scrapes video details:** title, URL, views (converted to a number), duration, thumbnail, video type, and published date
- ✅ **Search within channel:** Direct search using channel's search URL for reliable results
- ✅ **Handles different layouts:** Works with both grid and rich item layouts
- ✅ **Efficient scrolling:** Optimized scrolling strategy for both channel videos and search results
- ✅ **Incremental processing:** Processes and pushes videos in chunks as they are found
- ✅ **Resource optimization:** Blocks unnecessary resources (stylesheets, fonts, media)
- ✅ **Stores data in Apify Dataset:** Outputs structured JSON data for easy export
- ✅ **Configurable comment extraction:** Set the maximum number of comments to extract per video
- ✅ **User comment search:** Filter comments by author substring using `comments_user_search` for brand safety, user engagement, and social comment analysis

### 📥 Apify YouTube Scraper Input Parameters

The Actor accepts the following input parameters:

| Parameter      | Type      | Description                                                                                   | Default Value                           |
|----------------|-----------|-----------------------------------------------------------------------------------------------|-----------------------------------------|
| `channel`      | `string`  | A YouTube channel URL. The actor will append `/videos` if not present.                        | `"https://www.youtube.com/@CHANEL"`     |
| `search_query` | `string`  | Optional search term to filter videos on the channel. Leave empty to get all videos.          | `""`                                    |
| `max_videos`   | `integer` | The maximum number of videos to process from the channel.                                     | `50`                                    |
| `timeout`      | `integer` | Timeout in seconds for page operations.                                                       | `300`                                   |
| `video_details`| `boolean` | If enabled, visits each video page to extract description and comments.                       | `false`                                 |
| `comments_max` | `integer` | The maximum number of comments to extract per video (if `video_details` is enabled).          | `100`                                   |
| `comments_user_search` | `string` | Only include comments where the author's name contains this substring (case-insensitive). Useful for brand safety, user tracking, and social comment analysis. | `""` |

#### Example Input

```json
{
  "channel": "https://www.youtube.com/@CHANEL",
  "search_query": "perfume",
  "max_videos": 100,
  "timeout": 300,
  "video_details": true,
  "comments_max": 100,
  "comments_user_search": "chanel"
}
```

### 📤 Apify YouTube Scraper Output

The Actor outputs a JSON dataset containing video details for each processed video. Here's an example of how the output looks in the Apify Console:

Example of scraped YouTube channel data : https://i.ibb.co/zVZc86kR/output.jpg

#### Output Fields

| Field           | Type     | Description                                                |
|-----------------|----------|------------------------------------------------------------|
| duration        | string   | Video duration in MM:SS format                             |
| id              | string   | Unique YouTube video identifier                            |
| published       | string   | When the video was published (e.g., "4 days ago")          |
| published\_date  | string   | Actual date in YYYY-MM-DD format                           |
| thumbnail       | string   | High-quality thumbnail URL                                 |
| title           | string   | Video title                                                |
| type            | string   | Video type: "video", "short", or "live"                    |
| url             | string   | Full YouTube video URL                                     |
| views           | number   | View count (converted from strings like "1.6M" to numbers) |
| description     | string   | Video description (if `video_details` is enabled)          |
| comments        | array    | Array of extracted comments (if `video_details` is enabled, up to `comments_max`) |

#### Sample Output Object

```json
{
  "duration": "0:48",
  "id": "1eKokcaBwGg",
  "published": "4 days ago",
  "published_date": "2024-05-05",
  "thumbnail": "https://i.ytimg.com/vi/1eKokcaBwGg/maxresdefault.jpg",
  "title": "The Upcoming CHANEL Cruise 2025/26 Show — CHANEL Shows",
  "type": "video",
  "url": "https://www.youtube.com/watch?v=1eKokcaBwGg",
  "views": 34000,
  "description": "...",
  "comments": [
    {
      "author": "@username",
      "text": "Comment text...",
      "likes": "5",
      "time": "2 days ago"
    }
    // ... up to comments_max comments ...
  ]
}
```

### ⚙️ How This Apify YouTube Scraper Works

#### Channel Page Processing:

The Actor navigates to the provided YouTube channel URL:

- For regular scraping: appends `/videos` if not present
- For search: uses `/search?query=...` with the provided search term

#### Video Processing:

- Detects whether the page uses grid or rich item layout
- Extracts video information using optimized selectors
- Handles both regular videos and shorts
- Processes videos in chunks for efficient memory usage
- Optionally visits each video page to extract description and up to `comments_max` comments

#### Data Transformation:

- Converts view counts (e.g., "1.6M views") into numeric values
- Cleans and formats video durations
- Generates high-quality thumbnail URLs
- Identifies video types (normal/shorts/live)
- Converts relative dates to actual dates (YYYY-MM-DD format)

#### Result Storage:

All scraped data is pushed to an Apify Dataset in real-time, allowing for immediate access to the data as it's being collected.

***

#### ⚠️ Legal Disclaimer

This project is intended for educational and research purposes only. The use of this Actor must comply with YouTube's Terms of Service and robots.txt policies.

You are responsible for ensuring your use case does not violate YouTube website terms.
YouTube's content and trademarks are the property of YouTube, Inc.
Avoid aggressive scraping that could negatively impact YouTube's infrastructure.
If you intend to use this Actor for commercial purposes, consider reaching out to the YouTube API team for official data access.

### 🤝 Contributing

Have ideas for improvements? Found a bug? We welcome your input! You can:

- Report issues or suggest improvements directly through the Apify Console
- Use the "Report issue" button on the Actor's page
- Contact us through Apify's support channels

Your feedback helps us improve this Apify YouTube scraper and make it more useful for everyone!

### 🔧 Technical Details

#### Channel Page Processing

The Actor uses advanced techniques to process YouTube channel pages:

- Smart URL handling for videos and search
- Efficient resource blocking for optimal performance
- Intelligent scrolling for complete data extraction
- Robust error handling and retry mechanisms

#### Data Extraction

Our extraction process includes:

- Automatic layout detection (grid vs. rich item)
- View count normalization (K, M formats)
- Date standardization (YYYY-MM-DD)
- High-quality thumbnail generation
- Comment extraction with author filtering

#### Performance Optimizations

- Resource blocking (images, stylesheets, fonts)
- Efficient scrolling mechanisms
- Smart retry system
- Configurable timeouts
- Proxy support for reliable scraping

### 📈 SEO Benefits

- **Structured Data:** Clean, organized output perfect for SEO analysis
- **Metadata Extraction:** Get all video metadata for content optimization
- **Engagement Metrics:** Track views, comments, and user interaction
- **Content Analysis:** Analyze video titles and descriptions for SEO
- **Competitor Insights:** Monitor competitor content strategy
- **Trend Analysis:** Track video performance over time

### 🏆 Why This Apify YouTube Scraper is the Best Choice

- **Reliable:** Built on Apify's robust infrastructure
- **Scalable:** Handle large channels and high-volume scraping
- **Compliant:** Follows YouTube's terms of service and robots.txt
- **Feature-rich:** Advanced search, comment filtering, and brand safety features
- **Performance-optimized:** Efficient resource usage and proxy support
- **SEO-friendly:** Structured output perfect for content analysis and strategy

### Related Resources

- [YouTube Shorts Scraper](https://apify.com/runtime/youtube-shorts-scraper) - Specialized scraper for YouTube Shorts
- [Vimeo Video Scraper](https://apify.com/runtime/vimeo-video-scraper) - Similar functionality for Vimeo

***

**Ready to start scraping YouTube with Apify?** Deploy this Apify YouTube scraper and extract comprehensive video data, comments, and engagement metrics for your content analysis, SEO research, and brand monitoring needs.

# Actor input Schema

## `channel` (type: `string`):

A YouTube channel URL (e.g., "https://www.youtube.com/@Dior"). Mobile URLs (m.youtube.com) are automatically converted to desktop URLs. The actor will append "/videos" if needed.

## `search_query` (type: `string`):

Optional search term to filter videos on the channel. Leave empty to get all videos.

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

The maximum number of videos to load per channel.

## `timeout` (type: `integer`):

The timeout duration in seconds before the process is considered failed.

## `video_details` (type: `boolean`):

If enabled, visits each video page to extract description and comments.

## `comments_max` (type: `integer`):

The maximum number of comments to extract per video (if video\_details is enabled).

## `comments_user_search` (type: `string`):

Optional: Only include comments where the author's name contains this substring (case-insensitive). Useful for brand safety and user social comment analysis.

## `useApifyProxy` (type: `boolean`):

Whether to use Apify Proxy

## `proxyConfiguration` (type: `object`):

Choose to use no proxy, Apify Proxy, or provide custom proxy URLs.

## Actor input object example

```json
{
  "channel": "https://www.youtube.com/@CHANEL",
  "search_query": "",
  "max_videos": 30,
  "timeout": 300,
  "video_details": false,
  "comments_max": 100,
  "comments_user_search": "",
  "useApifyProxy": true,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": []
  }
}
```

# 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 = {
    "useApifyProxy": true,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": []
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("runtime/youtube-channel-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 = {
    "useApifyProxy": True,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": [],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("runtime/youtube-channel-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 '{
  "useApifyProxy": true,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": []
  }
}' |
apify call runtime/youtube-channel-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Youtube Scraper | Youtube Channel Scraper",
        "description": "YouTube Channel Scraper is an Apify Actor that scrapes video data and comments from a YouTube channel. It extracts key details such as video title, URL, view count, streaming time (in days), hashtags, description, comments count, and individual comments with user IDs.",
        "version": "0.48",
        "x-build-id": "Tr9ga3pOJw0wTS188"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/runtime~youtube-channel-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-runtime-youtube-channel-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/runtime~youtube-channel-scraper/runs": {
            "post": {
                "operationId": "runs-sync-runtime-youtube-channel-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/runtime~youtube-channel-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-runtime-youtube-channel-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "channel"
                ],
                "properties": {
                    "channel": {
                        "title": "Channel URL",
                        "type": "string",
                        "description": "A YouTube channel URL (e.g., \"https://www.youtube.com/@Dior\"). Mobile URLs (m.youtube.com) are automatically converted to desktop URLs. The actor will append \"/videos\" if needed.",
                        "default": "https://www.youtube.com/@CHANEL"
                    },
                    "search_query": {
                        "title": "Search Query",
                        "type": "string",
                        "description": "Optional search term to filter videos on the channel. Leave empty to get all videos.",
                        "default": ""
                    },
                    "max_videos": {
                        "title": "Maximum Videos",
                        "type": "integer",
                        "description": "The maximum number of videos to load per channel.",
                        "default": 30
                    },
                    "timeout": {
                        "title": "Timeout Duration",
                        "type": "integer",
                        "description": "The timeout duration in seconds before the process is considered failed.",
                        "default": 300
                    },
                    "video_details": {
                        "title": "Video Details",
                        "type": "boolean",
                        "description": "If enabled, visits each video page to extract description and comments.",
                        "default": false
                    },
                    "comments_max": {
                        "title": "Maximum Comments",
                        "type": "integer",
                        "description": "The maximum number of comments to extract per video (if video_details is enabled).",
                        "default": 100
                    },
                    "comments_user_search": {
                        "title": "Comments User Search",
                        "type": "string",
                        "description": "Optional: Only include comments where the author's name contains this substring (case-insensitive). Useful for brand safety and user social comment analysis.",
                        "default": ""
                    },
                    "useApifyProxy": {
                        "title": "Use Apify Proxy",
                        "type": "boolean",
                        "description": "Whether to use Apify Proxy",
                        "default": true
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Choose to use no proxy, Apify Proxy, or provide custom proxy URLs.",
                        "default": {}
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
