# YouTube Scraper (`solidcode/youtube-scraper`) Actor

\[💰 $0.5 / 1K]  Extract YouTube videos, shorts, channels, and playlists from search queries, URLs, handles, or the Trending tab. Returns titles, view counts, like counts, publish dates, channel info, thumbnails, and durations with localization across 45+ countries and 19+ languages.

- **URL**: https://apify.com/solidcode/youtube-scraper.md
- **Developed by:** [SolidCode](https://apify.com/solidcode) (community)
- **Categories:** Videos, Social media, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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 YouTube videos, shorts, channels, and playlists at scale. Feed the actor search queries, YouTube URLs (video, channel, playlist, shorts, or search pages), channel handles like `@mkbhd`, or enable Trending — mix and match in a single run. Each result comes back as a clean, structured row with titles, view counts, publish dates, channel info, thumbnails, and durations.

### Why This Scraper?

- **One input surface, four data types** — search queries, URLs, `@handles`, and Trending can all run in the same job, and every row is tagged with `recordType` (`video`, `short`, `channel`, or `playlist`) so you always know what you're looking at.
- **Powerful search filters** — narrow results by upload date, duration, sort order (relevance, upload date, view count, rating), and combine multiple video features (HD, 4K, HDR, Subtitles, Creative Commons, Live, 360°, VR180, 3D).
- **Real-time Trending feed** — pull the current Trending tab for any of 40+ supported countries with a single toggle.
- **Localized results** — get region-specific data across 40+ countries and 19+ interface languages with friendly dropdowns (no raw locale codes).
- **Channel enrichment** — add `fetchChannelInfo: true` and every channel input emits an extra row with subscribers, total views, video count, description, country, and creation date.
- **No-code friendly** — clean JSON inputs, dropdown menus with readable labels (no cryptic short codes), and sensible defaults so non-technical users can get started in seconds.
- **Pay only for results** — no compute-time charges. You pay a flat rate per 1,000 rows returned.

### Use Cases

**Market Research**
- Track share of voice on a topic or keyword over time
- Measure how a new product, album, or announcement is performing across creators
- Benchmark total view counts and publish cadence across a category

**Lead Generation**
- Build creator lists in any niche by searching keywords and collecting channel handles
- Enrich channel rosters with subscriber counts, contact info hints (channel description), and country targeting
- Find rising channels before they're discovered by competitors

**Content Strategy**
- See which titles, thumbnails, and durations are winning in your niche
- Identify trending formats (shorts vs. long-form) per category
- Study upload cadence and posting times of top performers

**Competitive Analysis**
- Monitor competitor channels — their full Videos tab plus Shorts
- Track competitor view counts and publish cadence week-over-week
- Spot when a competitor pivots topics or picks up a new trend

**Academic Research**
- Gather large, reproducible video datasets for media studies
- Study engagement patterns across countries and languages
- Sample trending content for cultural and political research

**Trend Monitoring**
- Pull Trending for multiple countries in parallel to compare regional trends
- Detect breakout topics as soon as YouTube surfaces them
- Track recurring trends across time windows using the upload date filter

### Getting Started

#### Simple Search

The fastest way to start — one search query and a result cap.

```json
{
    "searchQueries": ["mkbhd"],
    "maxResults": 20
}
````

#### Filtered Search

Narrow results with upload date, duration, sort order, features, and localization.

```json
{
    "searchQueries": ["electric vehicle review"],
    "uploadDate": "month",
    "duration": "medium",
    "sortBy": "viewCount",
    "features": ["hd", "subtitles"],
    "country": "us",
    "language": "en",
    "maxResults": 100
}
```

#### URL-Based Input

Paste any mix of YouTube URLs — video, channel, playlist, shorts, or search URLs. Toggle `fetchChannelInfo` to also get full channel stats for every channel URL.

```json
{
    "startUrls": [
        "https://www.youtube.com/watch?v=c347oYQO57A",
        "https://www.youtube.com/@mkbhd",
        "https://www.youtube.com/playlist?list=PLpjK416fmKwQ4Jb2vE2lK7K3vzoD9E5nQ"
    ],
    "fetchChannelInfo": true,
    "maxResults": 25
}
```

#### Trending Feed

Pull the current Trending tab for a specific country.

```json
{
    "getTrending": true,
    "country": "us",
    "maxResults": 50
}
```

#### Channel Handles with Shorts

Scrape multiple channels by handle and also collect their Shorts tab.

```json
{
    "youtubeHandles": ["@mkbhd", "@veritasium", "@LinusTechTips"],
    "includeShorts": true,
    "fetchChannelInfo": true,
    "maxResults": 30
}
```

### Input Reference

#### What to Scrape

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `searchQueries` | string\[] | `["mkbhd"]` | Keywords to search on YouTube. Each query runs independently. |
| `startUrls` | string\[] | `[]` | YouTube URLs — accepts video, channel (`/@handle`, `/channel/UC...`, `/c/...`, `/user/...`), playlist, shorts, and search result URLs in the same list. |
| `youtubeHandles` | string\[] | `[]` | Channel handles like `@mkbhd` or `mkbhd` (the leading `@` is optional). Each handle resolves to that channel's Videos tab. |
| `getTrending` | boolean | `false` | Also pull the current Trending tab for the selected country. |

#### Results

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `maxResults` | integer | `50` | Maximum rows per query, URL, or handle (0–500). For channels with Shorts enabled, this is a combined videos + shorts total. Set to `0` for as many as YouTube will serve. |
| `includeShorts` | boolean | `false` | When scraping a channel URL or handle, also pull the channel's Shorts tab in addition to Videos. Shorts count toward the same `maxResults` cap — videos fetch first, then shorts fill any remaining slots. |

#### Filters (Search Only)

These apply to keyword searches. URL, handle, playlist, and Trending inputs ignore them.

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `uploadDate` | string | `"any"` | Upload recency: Any time / Last hour / Today / This week / This month / This year. |
| `duration` | string | `"any"` | Video length: Any length / Short (under 4 min) / Medium (4–20 min) / Long (over 20 min). |
| `sortBy` | string | `"relevance"` | Sort order: Relevance / Upload date (newest first) / View count / Rating. |
| `features` | string\[] | `[]` | Multi-select video features: HD, Subtitles / CC, Creative Commons, Live, 4K, 360°, VR180, 3D, HDR. Combine as needed. |

#### Localization

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `country` | string | `"us"` | Country for result localization and Trending selection. Supports United States, United Kingdom, Canada, Australia, New Zealand, Ireland, France, Germany, Spain, Italy, Netherlands, Belgium, Portugal, Switzerland, Austria, Sweden, Norway, Denmark, Finland, Poland, Japan, South Korea, Hong Kong, Taiwan, Singapore, Malaysia, Thailand, Indonesia, Philippines, Vietnam, India, Brazil, Mexico, Argentina, Chile, Colombia, United Arab Emirates, Saudi Arabia, Turkey, Israel, South Africa, and Egypt. |
| `language` | string | `"en"` | Interface language for titles and metadata. English, French, German, Spanish, Italian, Portuguese, Dutch, Polish, Turkish, Russian, Japanese, Korean, Chinese (Simplified), Chinese (Traditional), Arabic, Hebrew, Thai, Vietnamese, Indonesian. |

#### Enrichment

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `fetchChannelInfo` | boolean | `false` | For channel URLs and handles, emit one extra row per channel with subscriber count, description, country, and creation date. |

### Output

Every row carries a `recordType` field so you can tell videos, shorts, channels, and playlists apart at a glance. Below is one example per type.

#### Video

```json
{
    "recordType": "video",
    "id": "qzGxK6Uiu04",
    "url": "https://www.youtube.com/watch?v=qzGxK6Uiu04",
    "title": "Incredible Wildlife in Stunning 16K HDR 120fps Dolby Vision",
    "description": "Experience the incredible wildlife in stunning 16K HDR 120fps Dolby Vision...",
    "duration": 4952,
    "durationText": "1:22:32",
    "viewCount": 19552604,
    "likeCount": null,
    "publishedText": "1 year ago",
    "publishedAt": "2025-04-24T17:46:41+00:00",
    "isLive": false,
    "isShort": false,
    "thumbnails": [
        {"url": "https://i.ytimg.com/vi/qzGxK6Uiu04/hq720.jpg", "width": 720, "height": 404}
    ],
    "channel": {
        "id": "UChB3UnDddahXU7FKZXmpzMA",
        "name": "8K Earth",
        "handle": "@8kEarth",
        "url": "https://www.youtube.com/@8kEarth"
    },
    "sourceInput": "8k hdr nature",
    "scrapedAt": "2026-04-24T17:46:41+00:00"
}
```

#### Short

*Illustrative example — individual YouTube video IDs can be deleted or set to private by their creator at any time, so don't rely on any specific ID in this document for live data.*

```json
{
    "recordType": "short",
    "id": "s3DrGkDvgNw",
    "url": "https://www.youtube.com/shorts/s3DrGkDvgNw",
    "title": "You won't believe this camera trick",
    "description": null,
    "duration": 49,
    "durationText": "0:49",
    "viewCount": 1824300,
    "likeCount": null,
    "publishedText": null,
    "publishedAt": "2026-03-11T15:22:04+00:00",
    "isLive": false,
    "isShort": true,
    "thumbnails": [
        {"url": "https://i.ytimg.com/vi/s3DrGkDvgNw/hq720.jpg", "width": 720, "height": 1280}
    ],
    "channel": {
        "id": "UCBJycsmduvYEL83R_U4JriQ",
        "name": "Marques Brownlee",
        "handle": "@mkbhd",
        "url": "https://www.youtube.com/@mkbhd"
    },
    "sourceInput": "https://www.youtube.com/shorts/s3DrGkDvgNw",
    "scrapedAt": "2026-04-24T17:46:41+00:00"
}
```

#### Channel

Emitted only when `fetchChannelInfo: true` and the input is a channel URL or handle.

```json
{
    "recordType": "channel",
    "id": "UCBJycsmduvYEL83R_U4JriQ",
    "url": "https://www.youtube.com/@mkbhd",
    "title": "Marques Brownlee",
    "handle": "@mkbhd",
    "subscriberCount": 20900000,
    "subscriberCountText": "20.9M subscribers",
    "videoCount": 1816,
    "viewCount": 5361395937,
    "description": "MKBHD: Quality Tech Videos | YouTuber | Geek | Consumer Electronics...",
    "country": "United States",
    "joinedAt": "2008-03-21",
    "joinedText": "Joined 21 Mar 2008",
    "thumbnail": "https://yt3.googleusercontent.com/ytc/mkbhd_avatar.jpg",
    "banner": "https://yt3.googleusercontent.com/ytc/mkbhd_banner.jpg",
    "sourceInput": "@mkbhd",
    "scrapedAt": "2026-04-24T17:46:41+00:00"
}
```

#### Playlist

Emitted once per playlist URL, alongside the videos it contains.

```json
{
    "recordType": "playlist",
    "id": "PLpjK416fmKwQ4Jb2vE2lK7K3vzoD9E5nQ",
    "url": "https://www.youtube.com/playlist?list=PLpjK416fmKwQ4Jb2vE2lK7K3vzoD9E5nQ",
    "title": "Retro Tech",
    "description": "Revisiting the best tech of decades past.",
    "videoCount": 42,
    "channel": {
        "id": "UCBJycsmduvYEL83R_U4JriQ",
        "name": "Marques Brownlee",
        "handle": "@mkbhd",
        "url": "https://www.youtube.com/@mkbhd"
    },
    "thumbnails": [
        {"url": "https://i.ytimg.com/vi/retrothumb/hqdefault.jpg", "width": 480, "height": 360}
    ],
    "sourceInput": "https://www.youtube.com/playlist?list=PLpjK416fmKwQ4Jb2vE2lK7K3vzoD9E5nQ",
    "scrapedAt": "2026-04-24T17:46:41+00:00"
}
```

#### Fields by Record Type

**Common fields (every row)**

| Field | Type | Description |
|-------|------|-------------|
| `recordType` | string | One of `video`, `short`, `channel`, `playlist`. |
| `id` | string | Canonical YouTube ID (videoId, channelId, or playlistId). |
| `url` | string | Public YouTube URL. |
| `title` | string | Video title, channel name, or playlist name. |
| `sourceInput` | string | The original query, URL, or handle that produced this row. |
| `scrapedAt` | string | ISO 8601 timestamp of when the row was captured. |

**Video & Short fields**

| Field | Type | Description |
|-------|------|-------------|
| `description` | string | null | Video description (snippet on search results, full text on direct video URLs). |
| `duration` | integer | null | Length in seconds. `null` for live streams. |
| `durationText` | string | null | Human-readable duration (e.g. `"12:34"`). |
| `viewCount` | integer | null | Total views. |
| `likeCount` | integer | null | Always `null` in this version — see Good to Know below. |
| `publishedText` | string | null | Human-readable publish label (e.g. `"2 weeks ago"`, `"vor 3 Monaten"`). |
| `publishedAt` | string | null | Resolved ISO-8601 UTC timestamp when available (English-locale searches and direct video URLs). Always UTC (`+00:00`). |
| `isLive` | boolean | `true` if the video is currently live. |
| `isShort` | boolean | `true` for YouTube Shorts. |
| `thumbnails` | object\[] | Thumbnail renditions with `url`, `width`, `height`. |
| `channel.id` | string | Parent channel ID. |
| `channel.name` | string | Parent channel name. |
| `channel.handle` | string | null | Channel handle (`@handle`). |
| `channel.url` | string | Channel URL. |

**Channel fields** (`recordType: "channel"`)

| Field | Type | Description |
|-------|------|-------------|
| `handle` | string | null | Channel handle in `@handle` form. |
| `subscriberCount` | integer | null | Numeric subscriber count. |
| `subscriberCountText` | string | null | Original label (e.g. `"20.9M subscribers"`). |
| `videoCount` | integer | null | Total videos uploaded. |
| `viewCount` | integer | null | All-time channel views. |
| `description` | string | null | Channel description. |
| `country` | string | null | Listed channel country. |
| `joinedAt` | string | null | Channel creation date (ISO format). |
| `joinedText` | string | null | Original "Joined" label from the About tab. |
| `thumbnail` | string | null | Channel avatar URL. |
| `banner` | string | null | Channel banner URL. |

**Playlist fields** (`recordType: "playlist"`)

| Field | Type | Description |
|-------|------|-------------|
| `description` | string | null | Playlist description if present. |
| `videoCount` | integer | null | Number of videos in the playlist. |
| `channel` | object | `{id, name, handle, url}` of the playlist owner. |
| `thumbnails` | object\[] | Playlist thumbnail renditions. |

### Tips for Best Results

- **Use exact phrases in quotes** (`"\"galaxy s25 review\""`) for narrower search results.
- **`maxResults: 0` pulls everything YouTube will serve** — typically 500–700 rows per search query and up to several thousand per channel. Set a concrete cap when you need a predictable run.
- **URL input is forgiving** — `youtu.be/abc123` short links, long `watch?v=` URLs with extra parameters, and mobile URLs all work.
- **Country and language matter** — they shift which videos YouTube surfaces, which trending feed is returned, and whether `publishedAt` comes back as a clean ISO date (English locales only).
- **Mix inputs freely** — one run can combine search queries, direct video URLs, channel handles, and Trending. Every row keeps a `sourceInput` field so you can group results by origin in your downstream pipeline.
- **Search filters are keyword-only** — applying `uploadDate` or `duration` to a URL, handle, or Trending input has no effect. To narrow channel uploads, post-filter on `publishedAt` and `duration` after extraction.

### Pricing

**No compute charges — you only pay per result returned.**

**$0.50 per 1,000 results.**

| Results | Cost |
|---------|------|
| 100 | $0.05 |
| 1,000 | $0.50 |
| 10,000 | $5.00 |

Every row in your dataset counts as one result, regardless of record type.

### Integrations

Export your data or plug it into your existing stack:

- **API** — Pull results programmatically via the Apify API
- **Webhooks** — Trigger downstream workflows when a run completes
- **Google Sheets** — One-click export to spreadsheets
- **Zapier / Make / n8n** — Automate with 1,000+ app connectors
- **Datasets** — Download as JSON, CSV, Excel, XML, or RSS

### Good to Know

- **`likeCount` is always `null`.** YouTube hides like counts behind an authenticated endpoint that rotates anti-abuse tokens every few weeks. Including it would make runs unreliable and more expensive — it is intentionally omitted.
- **Comments are not supported** in this actor. If you need comments and replies, use a dedicated YouTube comments scraper.
- **`publishedAt` ISO dates are populated for English-locale runs.** Non-English searches still return the human-readable `publishedText` (e.g. `"vor 3 Monaten"`) but leave `publishedAt` as `null`. Direct video URLs always include a clean ISO date regardless of locale.
- **Shorts pulled from a channel's Shorts tab arrive with limited metadata** — title, view count, thumbnail, and channel, but no duration or publish date. YouTube's Shorts feed doesn't include those fields; visiting each Short individually would multiply cost. If you need full Short metadata, pass the `/shorts/<id>` URL in `startUrls`.
- **Age-gated and members-only videos are not supported** — they require YouTube authentication that this actor does not use.
- **Trending is best-effort.** YouTube has been restricting the public, signed-out Trending feed throughout 2025–2026 and it now returns empty for many regions (including, intermittently, the US). If the Trending toggle returns zero rows, use a search query like `"trending"` with `sortBy: "viewCount"` as an approximation. The actor falls back gracefully with an explanatory log line when Trending is unavailable.
- **Streaming URLs, media formats, and caption transcripts are not returned.** They depend on a signed playback endpoint that rotates every few weeks — shipping them would make the actor break silently.

### Legal & Ethical Use

This actor is designed for legitimate market research, content strategy, competitive analysis, and academic research. You are responsible for complying with YouTube's Terms of Service, applicable laws, and data protection regulations in your jurisdiction. The actor only collects publicly visible data — no login, no paywalled or age-gated content, no personal data beyond what YouTube surfaces on public pages. Do not use extracted data for spam, harassment, impersonation, or any unlawful purpose.

# Actor input Schema

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

Keywords to search on YouTube (e.g., 'mkbhd review', 'guitar tutorial'). Each query runs independently. Leave empty if you only want to scrape URLs, handles, or Trending.

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

Paste YouTube URLs directly. Accepts video URLs (youtube.com/watch?v=...), channel URLs (/@handle, /channel/UC..., /c/..., /user/...), playlist URLs (/playlist?list=...), shorts URLs (/shorts/...), and search result URLs (/results?search\_query=...). Mix any of these in one list.

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

YouTube channel handles like '@mkbhd' or 'mkbhd'. Each handle resolves to that channel's Videos tab. The leading '@' is optional.

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

Also pull the current Trending tab for the selected country.

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

Maximum number of rows per query, URL, or handle. For channel inputs with Shorts enabled, the cap applies to the combined videos + shorts total (not per tab). Set to 0 to fetch every available result (YouTube typically caps search at roughly 500-700 per query). The actor may return a few extra from the final page — it won't fetch additional pages once this number is reached.

## `includeShorts` (type: `boolean`):

When scraping a channel URL or handle, also pull the channel's Shorts tab in addition to the Videos tab. Shorts count toward the same Maximum Results cap as videos — videos are fetched first, then shorts fill any remaining slots.

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

Only include videos uploaded within this time window. Applies to keyword searches only.

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

Filter search results by video length. Applies to keyword searches only.

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

Ordering for keyword-search results. Applies to keyword searches only.

## `features` (type: `array`):

Only include videos with these features. Multiple features can be combined. Applies to keyword searches only. "Subtitles" = videos with any caption track. "Creative Commons" = videos released under a CC license.

## `country` (type: `string`):

Localize results to this country. Affects which videos are shown, Trending selection, and currency-equivalent metadata.

## `language` (type: `string`):

Interface language for video titles and metadata returned in the response.

## `fetchChannelInfo` (type: `boolean`):

When scraping a channel URL or handle, also emit one extra row per channel with subscriber count, description, country, and creation date. Adds one extra result per channel.

## Actor input object example

```json
{
  "searchQueries": [],
  "startUrls": [],
  "youtubeHandles": [],
  "getTrending": false,
  "maxResults": 50,
  "includeShorts": false,
  "uploadDate": "any",
  "duration": "any",
  "sortBy": "relevance",
  "features": [],
  "country": "us",
  "language": "en",
  "fetchChannelInfo": false
}
```

# Actor output Schema

## `overview` (type: `string`):

Table of all results with the most useful fields at a glance.

## `videos` (type: `string`):

Per-video detail rows with duration, view count, like count, channel info, and thumbnails.

## `channels` (type: `string`):

Per-channel rows with subscriber count, description, country, and creation date. Only populated when 'Fetch Channel Details' is enabled.

# 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 = {
    "searchQueries": [],
    "startUrls": [],
    "youtubeHandles": [],
    "getTrending": false,
    "maxResults": 50,
    "includeShorts": false,
    "uploadDate": "any",
    "duration": "any",
    "sortBy": "relevance",
    "features": [],
    "country": "us",
    "language": "en",
    "fetchChannelInfo": false
};

// Run the Actor and wait for it to finish
const run = await client.actor("solidcode/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 = {
    "searchQueries": [],
    "startUrls": [],
    "youtubeHandles": [],
    "getTrending": False,
    "maxResults": 50,
    "includeShorts": False,
    "uploadDate": "any",
    "duration": "any",
    "sortBy": "relevance",
    "features": [],
    "country": "us",
    "language": "en",
    "fetchChannelInfo": False,
}

# Run the Actor and wait for it to finish
run = client.actor("solidcode/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 '{
  "searchQueries": [],
  "startUrls": [],
  "youtubeHandles": [],
  "getTrending": false,
  "maxResults": 50,
  "includeShorts": false,
  "uploadDate": "any",
  "duration": "any",
  "sortBy": "relevance",
  "features": [],
  "country": "us",
  "language": "en",
  "fetchChannelInfo": false
}' |
apify call solidcode/youtube-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Scraper",
        "description": "[💰 $0.5 / 1K]  Extract YouTube videos, shorts, channels, and playlists from search queries, URLs, handles, or the Trending tab. Returns titles, view counts, like counts, publish dates, channel info, thumbnails, and durations with localization across 45+ countries and 19+ languages.",
        "version": "1.0",
        "x-build-id": "2CH46LDncsATseqev"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/solidcode~youtube-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-solidcode-youtube-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/solidcode~youtube-scraper/runs": {
            "post": {
                "operationId": "runs-sync-solidcode-youtube-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/solidcode~youtube-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-solidcode-youtube-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",
                "properties": {
                    "searchQueries": {
                        "title": "Search Queries",
                        "type": "array",
                        "description": "Keywords to search on YouTube (e.g., 'mkbhd review', 'guitar tutorial'). Each query runs independently. Leave empty if you only want to scrape URLs, handles, or Trending.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "startUrls": {
                        "title": "YouTube URLs",
                        "type": "array",
                        "description": "Paste YouTube URLs directly. Accepts video URLs (youtube.com/watch?v=...), channel URLs (/@handle, /channel/UC..., /c/..., /user/...), playlist URLs (/playlist?list=...), shorts URLs (/shorts/...), and search result URLs (/results?search_query=...). Mix any of these in one list.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "youtubeHandles": {
                        "title": "Channel Handles",
                        "type": "array",
                        "description": "YouTube channel handles like '@mkbhd' or 'mkbhd'. Each handle resolves to that channel's Videos tab. The leading '@' is optional.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "getTrending": {
                        "title": "Include Trending",
                        "type": "boolean",
                        "description": "Also pull the current Trending tab for the selected country.",
                        "default": false
                    },
                    "maxResults": {
                        "title": "Maximum Results per Source",
                        "minimum": 0,
                        "maximum": 500,
                        "type": "integer",
                        "description": "Maximum number of rows per query, URL, or handle. For channel inputs with Shorts enabled, the cap applies to the combined videos + shorts total (not per tab). Set to 0 to fetch every available result (YouTube typically caps search at roughly 500-700 per query). The actor may return a few extra from the final page — it won't fetch additional pages once this number is reached.",
                        "default": 50
                    },
                    "includeShorts": {
                        "title": "Include Shorts on Channel Scrapes",
                        "type": "boolean",
                        "description": "When scraping a channel URL or handle, also pull the channel's Shorts tab in addition to the Videos tab. Shorts count toward the same Maximum Results cap as videos — videos are fetched first, then shorts fill any remaining slots.",
                        "default": false
                    },
                    "uploadDate": {
                        "title": "Upload Date",
                        "enum": [
                            "any",
                            "hour",
                            "today",
                            "week",
                            "month",
                            "year"
                        ],
                        "type": "string",
                        "description": "Only include videos uploaded within this time window. Applies to keyword searches only.",
                        "default": "any"
                    },
                    "duration": {
                        "title": "Duration",
                        "enum": [
                            "any",
                            "short",
                            "medium",
                            "long"
                        ],
                        "type": "string",
                        "description": "Filter search results by video length. Applies to keyword searches only.",
                        "default": "any"
                    },
                    "sortBy": {
                        "title": "Sort By",
                        "enum": [
                            "relevance",
                            "uploadDate",
                            "viewCount",
                            "rating"
                        ],
                        "type": "string",
                        "description": "Ordering for keyword-search results. Applies to keyword searches only.",
                        "default": "relevance"
                    },
                    "features": {
                        "title": "Video Features",
                        "uniqueItems": true,
                        "type": "array",
                        "description": "Only include videos with these features. Multiple features can be combined. Applies to keyword searches only. \"Subtitles\" = videos with any caption track. \"Creative Commons\" = videos released under a CC license.",
                        "items": {
                            "type": "string",
                            "enum": [
                                "hd",
                                "subtitles",
                                "creativeCommons",
                                "live",
                                "4k",
                                "360",
                                "vr180",
                                "3d",
                                "hdr"
                            ],
                            "enumTitles": [
                                "HD",
                                "Subtitles (any language)",
                                "Creative Commons",
                                "Live",
                                "4K",
                                "360°",
                                "VR180",
                                "3D",
                                "HDR"
                            ]
                        },
                        "default": []
                    },
                    "country": {
                        "title": "Country",
                        "enum": [
                            "us",
                            "gb",
                            "ca",
                            "au",
                            "nz",
                            "ie",
                            "fr",
                            "de",
                            "es",
                            "it",
                            "nl",
                            "be",
                            "pt",
                            "ch",
                            "at",
                            "se",
                            "no",
                            "dk",
                            "fi",
                            "pl",
                            "jp",
                            "kr",
                            "hk",
                            "tw",
                            "sg",
                            "my",
                            "th",
                            "id",
                            "ph",
                            "vn",
                            "in",
                            "br",
                            "mx",
                            "ar",
                            "cl",
                            "co",
                            "ae",
                            "sa",
                            "tr",
                            "il",
                            "za",
                            "eg"
                        ],
                        "type": "string",
                        "description": "Localize results to this country. Affects which videos are shown, Trending selection, and currency-equivalent metadata.",
                        "default": "us"
                    },
                    "language": {
                        "title": "Language",
                        "enum": [
                            "en",
                            "fr",
                            "de",
                            "es",
                            "it",
                            "pt",
                            "nl",
                            "pl",
                            "tr",
                            "ru",
                            "ja",
                            "ko",
                            "zh-CN",
                            "zh-TW",
                            "ar",
                            "he",
                            "th",
                            "vi",
                            "id"
                        ],
                        "type": "string",
                        "description": "Interface language for video titles and metadata returned in the response.",
                        "default": "en"
                    },
                    "fetchChannelInfo": {
                        "title": "Fetch Channel Details",
                        "type": "boolean",
                        "description": "When scraping a channel URL or handle, also emit one extra row per channel with subscriber count, description, country, and creation date. Adds one extra result per channel.",
                        "default": false
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
