# YouTube Scraper - Videos, Shorts, Channels & Playlists (`ragnum/youtube-scraper`) Actor

Scrape YouTube videos from searches, channels, playlists and single URLs: exact views, likes, publish times, durations, tags and channel data as parsed numbers. $0.30 per 1,000 videos, platform usage included. No minimums, failed inputs and duplicates are free.

- **URL**: https://apify.com/ragnum/youtube-scraper.md
- **Developed by:** [Ragnum](https://apify.com/ragnum) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.21 / 1,000 videos

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

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## YouTube Scraper — Videos, Shorts, Channels & Playlists

**Scrape YouTube videos from search results, channels, playlists and single video URLs — exact views and likes, publish times, durations, tags, categories, caption languages and channel data, with every number parsed for you. $0.30 per 1,000 videos, platform usage included.**

- No minimum per query, no per-query fee, no limit on inputs per run. A single video URL is welcome and returns exactly one row.
- Mix searches, video URLs, Shorts, `@handles`, channel URLs and playlists in one run.
- Numbers as numbers: `"1.2M views"` → `1200000`, in any interface language (the raw text is kept too).
- Failed inputs, unavailable videos and duplicates are free. No login, no cookies, no browser extension.

### Copy to your AI assistant

```text
Use the Apify actor ragnum/youtube-scraper to get YouTube videos.
Minimal input: {"searchQueries": ["lofi hip hop"], "maxResultsPerInput": 20}
Other inputs: startUrls (video / Shorts / channel / @handle / playlist / search URLs, mixed), includeDetails (default true),
uploadDate, duration, sortBy, features, contentType (channels: videos | shorts | streams | all), maxResults.
Each dataset row is one video. Price: $0.30 per 1,000 videos (error rows and duplicates are free).
Full docs: https://apify.com/ragnum/youtube-scraper
```

### Quick start

Search, most viewed this month, over 20 minutes:

```json
{ "searchQueries": ["python tutorial", "react tutorial"], "maxResultsPerInput": 100, "sortBy": "views", "uploadDate": "month", "duration": "long" }
```

A channel's latest Shorts and two single videos:

```json
{ "startUrls": ["https://www.youtube.com/@mkbhd/shorts", "https://youtu.be/dQw4w9WgXcQ", "https://www.youtube.com/watch?v=9bZkp7q19f0"], "maxResultsPerInput": 50 }
```

A playlist, listing fields only (fastest):

```json
{ "startUrls": ["https://www.youtube.com/playlist?list=PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI"], "includeDetails": false, "maxResultsPerInput": 200 }
```

### Input

| Field | Type | Default | What it does |
|---|---|---|---|
| `searchQueries` | string\[] | — | Keywords; each query is searched separately |
| `startUrls` | string\[] | — | Video, Shorts, `/live/`, channel (`/@handle`, `/channel/UC…`, `/c/…`, `/user/…`), `@handle`, `UC…` ID, playlist URL/ID, search URL — mixed |
| `maxResultsPerInput` | integer | 50 | 1–10,000 videos per query / channel / playlist (single video URLs always return one row) |
| `maxResults` | integer | — | Optional total cap for the run |
| `contentType` | enum | `videos` | Channels: `videos`, `shorts`, `streams`, `all` |
| `sortBy` | enum | `relevance` | Searches: `relevance`, `views`. Channels: `newest`, `popular`, `oldest` |
| `uploadDate` | enum | `any` | Searches: `hour`, `today`, `week`, `month`, `year` |
| `duration` | enum | `any` | Searches: `short` (< 3 min), `medium` (3–20 min), `long` (> 20 min) |
| `features` | enum\[] | `[]` | Searches: `hd`, `4k`, `live`, `subtitles`, `creativeCommons`, `hdr`, `vr180`, `360` |
| `includeDetails` | boolean | `true` | Read each video's page for exact time, likes, tags, category, captions list, full description. Same price either way |
| `hl` / `gl` | string | `en` / `US` | Interface language and region |
| `maxConcurrency` | integer | 10 | Parallel requests (1–20) |

### Output

One row per video. With details on:

| Field | Example | Notes |
|---|---|---|
| `videoId`, `url`, `type` | `dQw4w9WgXcQ`, …, `video` | `type`: `video`, `short`, `live`, `upcoming` |
| `title`, `description` | | Full description with details; snippet otherwise |
| `durationSeconds`, `durationText` | `213`, `3:33` | |
| `viewCount`, `viewCountText` | `1834999906`, `1,834,999,906 views` | Exact with details |
| `likeCount`, `likeCountText` | `19495941`, `19M` | |
| `commentCount`, `commentCountText` | `2400000`, `2.4M` | Rounded by YouTube |
| `publishedAt`, `publishedDate` | `2009-10-25T06:57:33.000Z`, `2009-10-25` | Exact, from the video details |
| `publishedTimeText`, `publishedAtEstimate` | `17 years ago`, — | The estimate is filled only when the exact time is unknown (listing-only rows) and is labelled as an estimate |
| `isLive`, `isShort`, `isFamilySafe`, `category` | `false`, `false`, `true`, `Music` | |
| `tags`, `hashtags` | `["rick astley", …]`, `["#RickAstley"]` | |
| `thumbnails` | `[{url, width, height}]` | Largest first |
| `channel` | `{id, handle, name, url, isVerified, subscriberCount}` | |
| `captionsAvailable` | `["en", "en-auto", "de-DE"]` | Caption languages; `-auto` = auto-generated. `null` when YouTube did not include the list for that video |
| `detailsFetched`, `detailsError` | `true`, `null` | `detailsError` says why some detail fields are empty |
| `source`, `scrapedAt` | | The input that produced the row; scrape time |

Example row (shortened):

```json
{
  "videoId": "dQw4w9WgXcQ", "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ", "type": "video",
  "title": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)",
  "durationSeconds": 213, "viewCount": 1834999906, "likeCount": 19495941, "commentCount": 2400000,
  "publishedAt": "2009-10-25T06:57:33.000Z", "category": "Music", "isFamilySafe": true,
  "tags": ["rick astley", "Never Gonna Give You Up"], "hashtags": ["#RickAstley"],
  "channel": { "id": "UCuAXFkgsw1L7xaCfnd5JJOw", "handle": "@RickAstleyYT", "name": "Rick Astley", "isVerified": true, "subscriberCount": 4560000 },
  "captionsAvailable": ["en", "en-auto", "de-DE", "ja", "pt-BR", "es-419"],
  "source": "https://www.youtube.com/watch?v=dQw4w9WgXcQ", "scrapedAt": "2026-11-08T10:03:49.757Z"
}
```

**Error rows.** When an input can't be returned (not a YouTube URL, channel not found, video unavailable, blocked after retries), the run writes `{ input, error, errorCode, retryable }` so automations can match every input to an outcome. Error rows are never charged. Filter them out with the `errorCode` field or use the "Overview" view.

**Run summary.** Every run stores `RUN_SUMMARY` in its key-value store: rows per input, why each input stopped, error rows, duplicates skipped, field fill rates and warnings.

### Pricing

Pay per result, platform usage included: **$0.30 per 1,000 videos** (`video` event, $0.0003). Nothing else is charged — no start fee, no per-query fee. Error rows and duplicates are free.

| Videos | Price |
|---|---|
| 100 | $0.03 |
| 1,000 | $0.30 |
| 10,000 | $3.00 |

Set "Maximum cost per run" in the run options to cap spending; the run stops cleanly when it is reached and keeps everything scraped so far. On the Apify Free plan, runs are a preview: the first input only and up to 20 videos.

### Limits and known gaps

- **Transcripts are not available** in this version. The list of caption languages is included when YouTube returns it and is often `null` (unknown) — treat it as a hint, not a guarantee.
- Like and comment counts are shown rounded by YouTube in some places (`19M`, `2.4M`); `likeCount` is exact when YouTube exposes it.
- `publishedAtEstimate` is computed from texts like "3 days ago" and is an estimate. `publishedAt` is exact when details are on.
- Searches can't be sorted by upload date any more (YouTube's own limitation); use `uploadDate` to get recent videos.
- Very large channels and searches are paginated by YouTube; a search usually ends after several hundred results.
- Thumbnail URLs are YouTube CDN links and may change over time.
- Only public, logged-out data. Private, members-only and age-restricted details are not returned.
- No video, audio or image downloads and no streaming URLs.

### FAQ

**Can I scrape a single video?** Yes. Put the URL in `startUrls`; you get one row and pay for one video.

**Does it work with Shorts and live streams?** Yes. Shorts URLs, a channel's Shorts tab (`contentType: "shorts"`) and live streams (`contentType: "streams"`) are supported; live rows have `type: "live"`.

**Are numbers parsed in other languages?** Yes — "2.550.184 Aufrufe", "21,4 Mio. Abonnenten", "948万回視聴" all become numbers. Set `hl` to get display texts in your language.

**Do I need a YouTube account or API key?** No.

**What if a video is unavailable?** You get an uncharged error row with `errorCode: "VIDEO_UNAVAILABLE"`.

### Legal

This actor collects only publicly available data that YouTube shows to logged-out visitors. You are responsible for how you use it: make sure your use complies with applicable laws (such as GDPR and CCPA, where personal data like channel names is involved) and with YouTube's Terms of Service. Don't use the data to spam, harass or profile individuals.

# Actor input Schema

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

Keywords to search on YouTube, one per line. Each query is searched separately and returns up to 'Max results per input' videos. Leave empty if you only use start URLs.

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

Any mix of: video URLs (watch, youtu.be, /shorts/, /live/), video IDs, channel URLs (/@handle, /channel/UC…, /c/…, /user/…), @handles, UC… channel IDs, playlist URLs or IDs, and search result URLs (/results?search_query=…). Single video URLs return exactly one row each.

## `maxResultsPerInput` (type: `integer`):

Maximum number of videos to return for each search query, channel or playlist (1–10,000). Ignored for single video URLs. You pay per video returned, so this caps the cost of each input.

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

Optional cap on the total number of videos for the whole run, across all inputs. Leave empty for no global cap.

## `contentType` (type: `string`):

For channel inputs: which tab to read. 'all' reads videos, then Shorts, then live streams until 'Max results per input' is reached. A channel URL that names a tab (e.g. /@name/shorts) uses that tab.

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

Searches: 'relevance' (default) or 'views' (most viewed first). Channels: 'newest' (default), 'popular' or 'oldest'. 'views' and 'popular' are interchangeable. Searches can't be sorted by upload date; use 'Upload date' to get recent videos instead.

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

Only return search results uploaded within this period.

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

Only return search results of this length: short = under 3 minutes, medium = 3–20 minutes, long = over 20 minutes (the same buckets as on YouTube).

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

Only return search results with all selected features: hd, 4k, live, subtitles, creativeCommons, hdr, vr180, 360.

## `includeDetails` (type: `boolean`):

On (default): also read each video's page for the exact publish time, exact view and like counts, full description, tags, category, family-safe flag, comment count, channel subscriber count and the list of caption languages. Off: listing fields only (title, views, duration, relative date, thumbnails), which is faster. The price per video is the same either way.

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

YouTube interface language code, e.g. en, de, fr, es, pt, ja. Affects display texts such as '1.2M views'; numbers are parsed for you either way.

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

Two-letter country code for regional results, e.g. US, GB, DE.

## `maxConcurrency` (type: `integer`):

How many videos are processed in parallel (1–20).

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

Proxy settings. The default works for most runs.

## `residentialFallback` (type: `boolean`):

When a request keeps getting blocked, retry it automatically through a different proxy type. Recommended.

## Actor input object example

```json
{
  "searchQueries": [
    "lofi hip hop"
  ],
  "startUrls": [
    "https://www.youtube.com/@mkbhd"
  ],
  "maxResultsPerInput": 50,
  "contentType": "videos",
  "sortBy": "relevance",
  "uploadDate": "any",
  "duration": "any",
  "features": [],
  "includeDetails": true,
  "hl": "en",
  "gl": "US",
  "maxConcurrency": 10,
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "residentialFallback": true
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `runSummary` (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 = {
    "searchQueries": [
        "lofi hip hop"
    ],
    "startUrls": [
        "https://www.youtube.com/@mkbhd"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ragnum/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": ["lofi hip hop"],
    "startUrls": ["https://www.youtube.com/@mkbhd"],
}

# Run the Actor and wait for it to finish
run = client.actor("ragnum/youtube-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).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": [
    "lofi hip hop"
  ],
  "startUrls": [
    "https://www.youtube.com/@mkbhd"
  ]
}' |
apify call ragnum/youtube-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ragnum/youtube-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/iLq1JOzHMJ6Cdczc7/builds/8sPVa7wRtzpQpbopb/openapi.json
