> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stophy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# YouTube playlist

> Read a YouTube playlist page with list in the link as JSON with the youtube-playlist parser. $1 per 1,000 calls. Send the page to scrape.

Reads a YouTube playlist page with list in the link and returns a list of videos as JSON.

## Make a request

Send the page's URL to [scrape](https://docs.stophy.dev/api-reference/endpoint/scrape.md) with a `json` format that names the parser. Get an API key in the [Quickstart](https://docs.stophy.dev/quickstart).

```bash cURL theme={null}
curl -X POST https://api.stophy.dev/v1/scrape \
  -H "Authorization: Bearer $STOPHY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://www.youtube.com/playlist?list=PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI","formats":[{"type":"json","parser":"youtube-playlist"}]}'
```

```typescript TypeScript theme={null}
const response = await fetch("https://api.stophy.dev/v1/scrape", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.STOPHY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://www.youtube.com/playlist?list=PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI",
    formats: [{ type: "json", parser: "youtube-playlist" }],
  }),
});
console.log(await response.json());
```

```python Python theme={null}
import os

import requests

response = requests.post(
    "https://api.stophy.dev/v1/scrape",
    headers={"Authorization": f"Bearer {os.environ['STOPHY_API_KEY']}"},
    json={
        "url": "https://www.youtube.com/playlist?list=PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI",
        "formats": [{"type": "json", "parser": "youtube-playlist"}],
    },
)
print(response.json())
```

## Read the response

The parser's data is in `data.json`. Its fields include `results`, `cursor`, `page` and `total`. This sample is cut to the first items.

```json theme={null}
{
  "success": true,
  "data": {
    "json": {
      "results": [
        {
          "id": "fOT0BUpITw8",
          "url": "https://www.youtube.com/watch?v=fOT0BUpITw8",
          "title": "BELLAKEO (Video Oficial) - Peso Pluma, Anitta",
          "description": null,
          "author": {
            "id": "0",
            "name": "Example user",
            "handle": null,
            "url": "https://example.com/example_user",
            "avatarUrl": null
          },
          "publishedAt": "2024-01-01T00:00:00.000Z",
          "durationSeconds": 235,
          "views": 774000000,
          "likes": null,
          "comments": null,
          "thumbnailUrl": "https://i.ytimg.com/vi/fOT0BUpITw8/hqdefault.jpg",
          "hashtags": [],
          "type": "video",
          "isShort": false,
          "isLive": false
        }
      ],
      "cursor": "4qmFsgKBARIkVkxQTEZncXVMbkw1OWFsQ2xfMlRRdk9pRDVWZ20xaENhR1NJGjRDQUY2SGxCVU9rTkhVV2xGUlZrMVVXdGFRazFVWXpOT1JFazFUWHBSZVU5RVdRJTNEJTNEmgIiUExGZ3F1TG5MNTlhbENsX...",
      "page": null,
      "total": 182,
      "playlist": {
        "id": "PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI",
        "url": "https://www.youtube.com/playlist?list=PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI",
        "title": "Popular Music Videos",
        "description": null,
        "author": {
          "id": "UC-9-kyTW8ZkZNDHQJ6FgpwQ",
          "name": "Music",
          "handle": null,
          "url": "https://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ",
          "avatarUrl": null
        },
        "videoCount": 182,
        "views": 1045675568,
        "hiddenVideos": 0,
        "thumbnailUrl": "https://i.ytimg.com/vi/fOT0BUpITw8/hqdefault.jpg"
      }
    }
  }
}
```

## Options

Send options in the `options` object of the `json` format.

| Option | What it does |
| - | - |
| `cursor` | The cursor from the previous response. Send it as is. |

## Price

\$1 per 1,000 calls. See [Pricing](https://docs.stophy.dev/account/pricing.md).

## Limits and errors

* The URL must be a YouTube playlist page with list in the link. Any other URL fails with `invalidRequest`.
* To read the next page, send the `cursor` from the response as the `cursor` option. Paging needs an API key.
* The answer comes back in `data.json`. If the page cannot be read, the call fails with an error code from [Errors](https://docs.stophy.dev/api-reference/errors.md).

## Related

* [Pre-built parsers](https://docs.stophy.dev/scrape/prebuilt-parsers) lists every parser.
* [Scrape](https://docs.stophy.dev/scrape/overview) has the options every scrape takes.
* [YouTube search](https://docs.stophy.dev/scrape/prebuilt-parsers/video/youtube-search.md)
* [YouTube video](https://docs.stophy.dev/scrape/prebuilt-parsers/video/youtube-video.md)
* [YouTube transcript](https://docs.stophy.dev/scrape/prebuilt-parsers/video/youtube-transcript.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.