# YouTube Video & Channel Data Extractor (`second_coming/youtube-data-extractor`) Actor

Extract video details, transcripts, comments, channel analytics, playlists, and search results from YouTube. Content marketing and video SEO research tool.

- **URL**: https://apify.com/second\_coming/youtube-data-extractor.md
- **Developed by:** [Richard P](https://apify.com/second_coming) (community)
- **Categories:** Social media, Education
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.02 / scan run

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 Video & Channel Data Extractor

Extract video metadata, channel info, search results, and comments from YouTube. Uses oEmbed API and page scraping — no API key required.

### Features

- **Video data extraction** — Title, description, duration, views, likes, upload date, thumbnails
- **Channel data extraction** — Name, subscribers, video count, avatar, banner, join date
- **YouTube search** — Search for videos by keyword, get title, views, publish date, duration
- **Comment extraction** — Scrape comments with author, text, likes, timestamps
- **Multi-source** — Accept video URLs, channel URLs, and search queries in one run
- **No API key needed** — Uses oEmbed API + page scraping via JSON-LD, ytInitialData, meta tags

### Input

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `videoUrls` | array of strings | | YouTube video URLs to extract |
| `channelUrls` | array of strings | | YouTube channel URLs to extract |
| `searchQueries` | array of strings | | Search terms to find videos |
| `maxResults` | integer | | Max videos per source (default: 30) |
| `includeComments` | boolean | | Scrape comments on videos (default: false) |
| `maxComments` | integer | | Max comments per video (default: 50) |

#### Example Input

```json
{
  "videoUrls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
  "channelUrls": ["https://www.youtube.com/@Veritasium"],
  "searchQueries": ["python tutorial 2026"],
  "maxResults": 20,
  "includeComments": true,
  "maxComments": 30
}
```

### Output Fields

Per video:
`videoId`, `title`, `description`, `channelName`, `channelUrl`, `duration` (seconds), `views`, `thumbnailUrl`, `uploadDate`, `publishedText`, `keywords`, `comments`, `sourceType`

Per channel:
`channelUrl`, `title`, `description`, `subscriberCount`, `videosCount`, `avatarUrl`, `bannerUrl`, `channelId`, `joinedDate`, `sourceType`

Per search:
`searchQuery`, `results` (array of video search results), `sourceType`

### Local Development

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
apify run --purge
```

### Limitations

- YouTube may block aggressive scraping — add delays between requests
- Comment extraction depends on ytInitialData being present in page HTML
- Some metadata may be missing without a valid API key
- Search results may vary by region/language

# Actor input Schema

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

List of YouTube video URLs to extract data from.

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

List of YouTube channel URLs to extract data from.

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

Search terms to find YouTube videos.

## `maxResults` (type: `integer`):

Maximum number of videos to extract per source.

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

Whether to scrape comments on each video.

## `maxComments` (type: `integer`):

Maximum number of comments to extract per video.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "channelUrls": [],
  "searchQueries": [],
  "maxResults": 30,
  "includeComments": false,
  "maxComments": 50
}
```

# Actor output Schema

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

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

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

```

## MCP server setup

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

```

## OpenAPI specification

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