# Youtube Scraper (`jasondev/youtube-scraper`) Actor

Extract comprehensive data from YouTube including videos, channels, playlists, and search results. This Actor supports multiple filters, languages, and countries for customized data collection.

- **URL**: https://apify.com/jasondev/youtube-scraper.md
- **Developed by:** [Jason Giang](https://apify.com/jasondev) (community)
- **Categories:** Social media, Agents
- **Stats:** 65 total users, 1 monthly users, 100.0% runs succeeded, 3 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 Scraper

Extract comprehensive data from YouTube including videos, channels, playlists, and search results. This Actor supports multiple filters, languages, and countries for customized data collection.

### Features

- 🔍 **Search Functionality**: Search YouTube with keywords
- 📺 **Channel Scraping**: Extract videos from YouTube channels using handles or URLs
- 📋 **Playlist Support**: Scrape entire playlists
- 🔗 **URL Processing**: Direct video, channel, and playlist URL scraping
- 🌍 **Multi-language Support**: Configure language and country settings
- ⚡ **Fast & Efficient**: Optimized for speed and reliability
- 📊 **Rich Data**: Get views, likes, duration, channel info, and more

### Input Configuration

#### Basic Options

- **Start URLs**: YouTube URLs (videos, channels, playlists)
- **Keywords**: Search terms to find videos
- **YouTube Handles**: Channel handles (e.g., @MrBeast)
- **Max Items**: Maximum number of videos to scrape
- **Max Items Per Query**: Limit per keyword/channel/playlist

#### Filters

- **Location (gl)**: Country code (US, GB, DE, etc.)
- **Language (hl)**: Language code (en, de, fr, etc.)
- **Upload Date**: Filter by recency (hour, today, week, month, year)
- **Duration**: Filter by video length (short, medium, long)
- **Sort By**: Order results (relevance, upload date, view count, rating)

#### Advanced Options

- **Get Trending**: Retrieve trending videos
- **Get Channel Info**: Include detailed channel information
- **Proxy Configuration**: Configure proxy settings

### Output

Each scraped video includes:

```json
{
  "type": "video",
  "id": "VMYmerFEvHE",
  "title": "Video Title",
  "url": "https://www.youtube.com/watch?v=VMYmerFEvHE",
  "description": "Full video description...",
  "duration": 170,
  "views": 430284,
  "likes": 0,
  "channel.id": "UCFVEEjwyX0_wZkCcwHE8tig",
  "channel.name": "Channel Name",
  "channel.url": "https://www.youtube.com/channel/UCFVEEjwyX0_wZkCcwHE8tig",
  "channelIcon": "https://yt3.ggpht.com/...",
  "thumbnails": {
    "id": "VMYmerFEvHE",
    "width": 720,
    "height": 404,
    "url": "https://i.ytimg.com/vi/VMYmerFEvHE/hq720.jpg"
  },
  "isLive": false,
  "isShorts": false,
  "isPrivate": false,
  "keywords": ["keyword1", "keyword2", "keyword3"],
  "embedUrl": "https://www.youtube.com/embed/VMYmerFEvHE",
  "isFamilySafe": true,
  "publishDate": "2025-05-06T12:00:00.000Z",
  "uploadDate": "2025-05-06T12:00:00.000Z"
}
```

### Usage Examples

#### Example 1: Search for Videos

```json
{
  "keywords": ["apify tutorial", "web scraping"],
  "maxItems": 50,
  "sortBy": "view_count"
}
```

#### Example 2: Scrape a Channel

```json
{
  "youtubeHandles": ["@MrBeast"],
  "maxItemsPerQuery": 100,
  "getChannelInfo": true
}
```

#### Example 3: Extract Playlist Videos

```json
{
  "startUrls": [
    { "url": "https://www.youtube.com/playlist?list=PLxxxxxx" }
  ],
  "maxItems": 200
}
```

#### Example 4: Multiple Sources

```json
{
  "keywords": ["javascript tutorial"],
  "youtubeHandles": ["@FireshipIO"],
  "startUrls": [
    { "url": "https://www.youtube.com/@Fireship" }
  ],
  "maxItems": 100,
  "uploadDate": "month"
}
```

### Limitations

- **Rate limiting** applies based on YouTube's policies
- **Subscriber counts and like counts** are not available due to YouTube API limitations
- Some data may require authentication
- Proxy usage recommended for high-volume scraping

### Support

For issues or questions, please create an issue in the repository.

# Actor input Schema

## `startUrls` (type: `array`):

YouTube URLs to scrape (videos, channels, playlists, search results)

## `keywords` (type: `array`):

Keywords to search on YouTube

## `youtubeHandles` (type: `array`):

YouTube channel handles (e.g., @channelname)

## `maxItems` (type: `integer`):

Maximum number of items to scrape (0 = unlimited). Default is 20 to keep runs within the 5-minute limit; increase if you need more results and can tolerate longer runs.

## `maxItemsPerQuery` (type: `integer`):

Maximum items to scrape per keyword/channel/playlist. Default is 20 to match maxItems and avoid timeouts.

## `gl` (type: `string`):

Location for search results (US, GB, DE, etc.)

## `hl` (type: `string`):

Language for search results (en, de, fr, etc.)

## `uploadDate` (type: `string`):

Filter by upload date

## `duration` (type: `string`):

Filter by video duration

## `sortBy` (type: `string`):

Sort order for search results

## `maxRunSeconds` (type: `integer`):

Wall-clock budget in seconds. When reached, the run stops enriching and exits cleanly with whatever it has already saved, instead of being killed by the platform timeout. Set this a bit BELOW your Actor's configured timeout (e.g. 150 for a 180s timeout). 0 = no limit.

## `getTrending` (type: `boolean`):

Retrieve trending videos

## `getChannelInfo` (type: `boolean`):

Include detailed channel information

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

Proxy settings for the scraper

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.youtube.com/@MrBeast"
    }
  ],
  "keywords": [
    "apify tutorial"
  ],
  "youtubeHandles": [],
  "maxItems": 20,
  "maxItemsPerQuery": 20,
  "gl": "US",
  "hl": "en",
  "uploadDate": "all",
  "duration": "all",
  "sortBy": "relevance",
  "maxRunSeconds": 0,
  "getTrending": false,
  "getChannelInfo": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# 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 = {
    "startUrls": [
        {
            "url": "https://www.youtube.com/@MrBeast"
        }
    ],
    "keywords": [
        "apify tutorial"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("jasondev/youtube-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 = {
    "startUrls": [{ "url": "https://www.youtube.com/@MrBeast" }],
    "keywords": ["apify tutorial"],
}

# Run the Actor and wait for it to finish
run = client.actor("jasondev/youtube-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 '{
  "startUrls": [
    {
      "url": "https://www.youtube.com/@MrBeast"
    }
  ],
  "keywords": [
    "apify tutorial"
  ]
}' |
apify call jasondev/youtube-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

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