# YouTube Playlist Scraper (`w3crawler/youtube-playlist-scraper`) Actor

Extract public video listings and playlist metadata from YouTube playlist pages with Playwright.

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

## Pricing

from $2.99 / 1,000 playlists

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/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 Public Playlist Scraper

Collect deduplicated video records from public YouTube playlist pages. The actor requests the ordinary rendered playlist page and parses its embedded `ytInitialData`; it does not call YouTube's private browse API, download media, access private playlists, or bypass authentication or CAPTCHAs.

### Dataset

Each video row includes the canonical playlist and watch URLs, playlist title and description when public, playlist owner, playlist video/view counts, last-updated text, playlist thumbnail, video title, ID, position, duration and seconds, channel details, displayed and parsed view counts, publication text, accessibility text, thumbnail sizes, renderer provenance, locale context, continuation visibility, and scrape time.

If the public page is blocked, unavailable, or exposes no video items, the actor writes a diagnostic with exactly `url`, `error`, `errorCode`, and `scrapedAt`. The `OUTPUT` key-value record contains per-run counts and proxy state.

### Input

| Field | Default | Description |
| --- | --- | --- |
| `playlistUrls` | required | One to 50 HTTPS public YouTube playlist URLs with a valid `list` parameter. |
| `maxItems` | `100` | Maximum unique video rows retained per playlist page, from 1 to 5000. |
| `languageCode` / `countryCode` | `en` / `US` | Locale context passed to the public page and recorded in each row. |
| `proxyConfiguration` | none | Optional account-authorized Apify Proxy or credential-free HTTP/SOCKS URLs. |
| `enableProxyFallback` | `true` | Try one ordinary configured Apify Proxy request after a direct page failure. |
| `includeDiagnostics` | `true` | Keep bounded access and parsing diagnostics in the dataset. |
| `requestDelayMs` / `requestTimeoutSecs` | `250` / `60` | Bounded pacing and request timeout. |

Example:

```json
{
  "playlistUrls": ["https://www.youtube.com/playlist?list=PL2JtvykrieUxaLXkeuXRHb-pJB9XpVWtd"],
  "maxItems": 25,
  "languageCode": "en",
  "countryCode": "US",
  "proxyConfiguration": { "useApifyProxy": true },
  "enableProxyFallback": true,
  "includeDiagnostics": true
}
```

### Coverage and reliability

- Uses a fixed ordinary browser User-Agent and public HTML only.
- The initial public playlist page may expose a continuation marker. The actor records that fact but does not call the private continuation endpoint; `maxItems` limits the records retained from the public page response.
- Proxy URLs, credentials, cookies, request identities, and operational proxy details are never written to dataset rows.
- No fingerprint spoofing, stealth patches, CAPTCHA/login bypass, private or alternate YouTube clients, or hidden API calls are implemented.
- Public counts, order, metadata, and availability are point-in-time observations. Deleted, age-restricted, private, region-restricted, or layout-changed items may be omitted.

### Local verification

```powershell
npm test
npx --yes apify validate-schema
$env:APIFY_LOCAL_STORAGE_DIR = 'storage'
npx --yes apify run --purge --input-file INPUT.json
node validate-datasets.js
```

The checked-in `storage/` sample is refreshed from the latest local public-page run. Preserve it before replacing it.

# Changelog

This Actor's version history is a separate document: https://apify.com/w3crawler/youtube-playlist-scraper/changelog.md

# Actor input Schema

## `playlistUrls` (type: `array`):

HTTPS YouTube playlist URLs containing a valid list query parameter.

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

Maximum public video rows retained from each playlist page, from 1 to 5000.

## `languageCode` (type: `string`):

Language context sent to the public playlist page.

## `countryCode` (type: `string`):

Two-letter country context sent to the public playlist page.

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

Optional account-authorized Apify Proxy or credential-free HTTP/SOCKS URLs.

## `enableProxyFallback` (type: `boolean`):

After a direct public-page failure, try one ordinary configured Apify Proxy request.

## `includeDiagnostics` (type: `boolean`):

Write bounded access or parsing diagnostics to the dataset.

## `requestDelayMs` (type: `integer`):

Bounded pacing delay between playlist page requests.

## `requestTimeoutSecs` (type: `integer`):

Timeout for each public playlist page request.

## Actor input object example

```json
{
  "playlistUrls": [
    "https://www.youtube.com/playlist?list=PL2JtvykrieUxaLXkeuXRHb-pJB9XpVWtd"
  ],
  "maxItems": 100,
  "languageCode": "en",
  "countryCode": "US",
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "enableProxyFallback": true,
  "includeDiagnostics": true,
  "requestDelayMs": 250,
  "requestTimeoutSecs": 60
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `keyValueStore` (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 = {
    "playlistUrls": [
        "https://www.youtube.com/playlist?list=PL2JtvykrieUxaLXkeuXRHb-pJB9XpVWtd"
    ],
    "maxItems": 100,
    "languageCode": "en",
    "countryCode": "US",
    "proxyConfiguration": {
        "useApifyProxy": false
    },
    "enableProxyFallback": true,
    "includeDiagnostics": true,
    "requestDelayMs": 250,
    "requestTimeoutSecs": 60
};

// Run the Actor and wait for it to finish
const run = await client.actor("w3crawler/youtube-playlist-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 = {
    "playlistUrls": ["https://www.youtube.com/playlist?list=PL2JtvykrieUxaLXkeuXRHb-pJB9XpVWtd"],
    "maxItems": 100,
    "languageCode": "en",
    "countryCode": "US",
    "proxyConfiguration": { "useApifyProxy": False },
    "enableProxyFallback": True,
    "includeDiagnostics": True,
    "requestDelayMs": 250,
    "requestTimeoutSecs": 60,
}

# Run the Actor and wait for it to finish
run = client.actor("w3crawler/youtube-playlist-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 '{
  "playlistUrls": [
    "https://www.youtube.com/playlist?list=PL2JtvykrieUxaLXkeuXRHb-pJB9XpVWtd"
  ],
  "maxItems": 100,
  "languageCode": "en",
  "countryCode": "US",
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "enableProxyFallback": true,
  "includeDiagnostics": true,
  "requestDelayMs": 250,
  "requestTimeoutSecs": 60
}' |
apify call w3crawler/youtube-playlist-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,w3crawler/youtube-playlist-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/b3ahwhi7a9cSS4CLQ/builds/Q3QzkURIAO6Gvzcxh/openapi.json
