# YouTube Playlist Scraper — All Videos, Views & Order (`dottti/youtube-playlist-scraper`) Actor

Scrape every video in a YouTube playlist: title, views, duration and position in the list, plus the playlist's own title and totals. No API key, no quota.

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

## Pricing

from $1.40 / 1,000 video delivereds

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 Playlist Scraper — All Videos, Views & Order

Scrape every video in a YouTube playlist, in order: title, views, duration and position, plus the playlist's own title and totals. No API key, no quota, no login.

### Output

```json
{
  "playlistId": "PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj",
  "playlistTitle": "Pop Music Playlist - Timeless Pop Songs",
  "playlistVideoCount": 200,
  "position": 1,
  "videoId": "ekr2nIex040",
  "url": "https://www.youtube.com/watch?v=ekr2nIex040",
  "title": "ROSÉ & Bruno Mars - APT. (Official Music Video)",
  "viewCount": 2600000000,
  "viewCountText": "2.6B views",
  "lengthText": "2:54",
  "lengthSeconds": 174
}
```

### Two details that matter

**Position is order-of-appearance, and says so.** YouTube does not publish an index field on playlist pages, so `position` is assigned from document order — meaning position *within what was fetched*. A test asserts that skipped rows do not consume a number, so positions are always contiguous.

**Playlist IDs are validated, not assumed.** A video ID is 11 characters with no prefix; a playlist ID starts with `PL`, `UU`, `LL`, `FL`, `OL` or `RD`. Passing a video ID by mistake is rejected rather than sent to a playlist page that does not exist. Any URL carrying `list=` also works, including a watch URL that happens to be playing from a playlist.

### Blocked playlists are never charged

YouTube refuses some datacenter IPs with "Sign in to confirm you're not a bot", returned as a normal 200 page with no data. Billing for that would charge you for this Actor's IP being refused, so those rows are written with `blocked: true` and `error: "blocked_by_youtube"` and **no event fires**.

Set `proxyConfiguration` to Apify Proxy with `RESIDENTIAL` groups to avoid it.

### Input

| Field | What it does |
| --- | --- |
| `playlists` | Playlist URLs or IDs. Any URL with `list=` works. |
| `maxVideosPerPlaylist` | Cap per playlist, and therefore on cost. One request returns about 100 videos. |
| `includePlaylistInfo` | Attach playlist title, URL and totals to every row. |
| `language` / `country` | Two-letter codes. |

#### Example

```json
{
  "playlists": ["https://www.youtube.com/playlist?list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj"],
  "maxVideosPerPlaylist": 200
}
```

### Notes and limits

- Public playlists only. Private and unlisted playlists are not accessible without a login, and are reported as empty rather than guessed at.
- View counts are YouTube's displayed values, abbreviated for large numbers ("2.6B views"). Both the number and the original string are returned.
- One request returns roughly 100 videos. Deeper paging is not performed, so a 500-video playlist returns its first 100.
- `playlistVideoCount` is the playlist's own stated total, which may exceed the number of rows returned. The difference tells you what was not fetched.

### Development

```bash
npm install
npm test
node src/main.js
```

# Actor input Schema

## `playlists` (type: `array`):

Playlist URLs or IDs. Any URL carrying list= works, as does a bare ID starting with PL, UU, LL, FL, OL or RD.

## `maxVideosPerPlaylist` (type: `integer`):

Hard cap per playlist, and therefore on cost. One request returns about 100 videos.

## `includePlaylistInfo` (type: `boolean`):

Adds the playlist title, its own URL and its total video and view counts to each row.

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

Two-letter language code used for titles.

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

Two-letter country code. Affects regional availability.

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

YouTube throttles bursts. Raise this if the log shows 429 or bot checks.

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

Retries with exponential backoff on 403, 429 and 5xx.

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

YouTube refuses some datacenter IPs with a bot check. Blocked playlists are never charged, but a residential proxy avoids the problem.

## Actor input object example

```json
{
  "playlists": [
    "https://www.youtube.com/playlist?list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj"
  ],
  "maxVideosPerPlaylist": 200,
  "includePlaylistInfo": true,
  "language": "en",
  "country": "US",
  "requestDelayMs": 600,
  "maxRetries": 4,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

Position in the playlist, video ID and URL, title, view count (numeric and as shown), duration, approximate publish date, plus the playlist title, URL, total video count and total view count.

## `runSummary` (type: `string`):

Per-playlist outcome: videos delivered, the playlist's own total, renderer shape used, and any playlist that failed or was blocked.

# 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 = {
    "playlists": [
        "https://www.youtube.com/playlist?list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dottti/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 = { "playlists": ["https://www.youtube.com/playlist?list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj"] }

# Run the Actor and wait for it to finish
run = client.actor("dottti/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 '{
  "playlists": [
    "https://www.youtube.com/playlist?list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj"
  ]
}' |
apify call dottti/youtube-playlist-scraper --silent --output-dataset

```

## MCP server setup

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