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

Search YouTube Music playlists or browse playlist URLs directly. Saves rich playlist and deduplicated track metadata through first-party YouTube Music endpoints.

- **URL**: https://apify.com/w3crawler/youtube-music-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 Music Playlist Scraper

Collects rich records for public YouTube and YouTube Music playlists. The actor uses ordinary public HTML pages and parses the embedded `ytInitialData` payload that the page itself exposes. It does not use private service calls or signed media URLs.

### Dataset fields

Each playlist record includes:

- playlist ID, canonical public URL, title, description, description length, creator/channel details, reported counts, privacy text, thumbnails with dimensions, source and search rank
- deduplicated tracks with video ID, title, description, accessibility text, artist objects, album, duration and seconds, views, publication text, badges, explicit/live/upcoming flags, playlist position, channel details, thumbnails with dimensions, and public YouTube/YouTube Music URLs
- public extraction provenance, locale, request limits, page availability, initial item coverage, continuation visibility, and scrape time

If a public page exposes a continuation marker, the dataset reports it. This implementation keeps requests bounded to public page/search pagination and does not replay opaque continuation commands.

### Input

Use at least one search query or direct playlist URL. `playlistUrls` remains accepted as a compatibility alias for `startUrls`.

| Field | Default | Description |
|---|---:|---|
| `searchQueries` | — | Playlist search terms. |
| `startUrls` | — | Public YouTube or YouTube Music playlist URLs. |
| `playlistUrls` | — | Legacy alias for `startUrls`. |
| `maxItems` | 20 | Maximum unique playlist records, 1–100. |
| `maxTracks` | 100 | Maximum tracks per playlist, 1–500. |
| `maxPages` | 3 | Maximum public search pages per query, 1–10. |
| `languageCode` | `en` | Public-page language context. |
| `countryCode` | `US` | Public-page country context. |
| `proxyConfiguration` | — | Optional account-authorized Apify Proxy or credential-free HTTP/SOCKS URLs. |
| `enableProxyFallback` | `true` | Try one configured Apify Proxy after a direct request fails. |
| `includeDiagnostics` | `true` | Write bounded four-field diagnostics. |
| `requestDelayMs` | 250 | Delay between requests, 0–5000 ms. |
| `requestTimeoutSecs` | 60 | Per-request timeout, 15–180 seconds. |
| `maxRetries` | 1 | Bounded retries per request, 0–3. |

Example:

```json
{
  "searchQueries": ["indie road trip playlists"],
  "startUrls": ["https://www.youtube.com/playlist?list=PLxxxx"],
  "maxItems": 5,
  "maxTracks": 50,
  "maxPages": 2,
  "includeDiagnostics": true,
  "proxyConfiguration": { "useApifyProxy": false }
}
```

### Reliability and verification

Requests use fixed ordinary public-page headers, bounded retries, pacing, and optional account-authorized Apify Proxy routing. There is no CAPTCHA/login bypass, request-identity spoofing, browser automation, or credential storage. When access is blocked or a page lacks playlist data, the actor preserves successful records and emits a bounded diagnostic instead of exposing response bodies or credentials.

Verify locally with `npm test`, `npx apify validate-schema`, `npx apify run --purge --input-file INPUT.json`, and `node validate-datasets.js`. Deploy with `npx apify actors push <actor-id> --version 2.0 --build-tag latest`, then call the cloud Actor with the bounded QA inputs and compare playlist IDs, track counts, required fields, duplicates, and provenance.

# Changelog

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

# Actor input Schema

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

Search terms used with YouTube's public playlist filter.

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

Public YouTube or YouTube Music playlist URLs. This is the preferred direct-URL field.

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

Backward-compatible alias for startUrls.

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

Maximum unique playlist records saved (1–100).

## `maxTracks` (type: `integer`):

Maximum deduplicated track records included per playlist (1–500).

## `maxPages` (type: `integer`):

Bounded number of public search pages per query (1–10).

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

Language context sent to public pages.

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

Two-letter country context sent to public pages.

## `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 extraction diagnostics to the dataset.

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

Bounded pacing delay between public page requests.

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

Timeout for each public page request.

## `maxRetries` (type: `integer`):

Bounded retries after a public page request fails.

## Actor input object example

```json
{
  "searchQueries": [
    "Adele playlists"
  ],
  "maxItems": 20,
  "maxTracks": 100,
  "maxPages": 3,
  "languageCode": "en",
  "countryCode": "US",
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "enableProxyFallback": true,
  "includeDiagnostics": true,
  "requestDelayMs": 250,
  "requestTimeoutSecs": 60,
  "maxRetries": 1
}
```

# 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 = {
    "searchQueries": [
        "Adele playlists"
    ],
    "maxItems": 20,
    "maxTracks": 100,
    "maxPages": 3,
    "languageCode": "en",
    "countryCode": "US",
    "proxyConfiguration": {
        "useApifyProxy": false
    },
    "enableProxyFallback": true,
    "includeDiagnostics": true,
    "requestDelayMs": 250,
    "requestTimeoutSecs": 60,
    "maxRetries": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("w3crawler/youtube-music-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 = {
    "searchQueries": ["Adele playlists"],
    "maxItems": 20,
    "maxTracks": 100,
    "maxPages": 3,
    "languageCode": "en",
    "countryCode": "US",
    "proxyConfiguration": { "useApifyProxy": False },
    "enableProxyFallback": True,
    "includeDiagnostics": True,
    "requestDelayMs": 250,
    "requestTimeoutSecs": 60,
    "maxRetries": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("w3crawler/youtube-music-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 '{
  "searchQueries": [
    "Adele playlists"
  ],
  "maxItems": 20,
  "maxTracks": 100,
  "maxPages": 3,
  "languageCode": "en",
  "countryCode": "US",
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "enableProxyFallback": true,
  "includeDiagnostics": true,
  "requestDelayMs": 250,
  "requestTimeoutSecs": 60,
  "maxRetries": 1
}' |
apify call w3crawler/youtube-music-playlist-scraper --silent --output-dataset

```

## MCP server setup

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