Skip to content

How to get every video in a YouTube playlist as JSON, without an API key

By Hayden Barnett · · 5 min read

A YouTube playlist is the list behind a youtube.com/playlist?list=... link. To get it as JSON without a Google Cloud project, an API key or a quota, send the playlist id to one GET and follow the continuationToken it returns until that token is null:

export FETCHPROOF_API_KEY=fp_live_xxx

curl -s "https://api.fetchproof.com/v1/youtube/playlist?playlist_id=PLF98rxtslw6s" \
  --header "x-api-key: $FETCHPROOF_API_KEY"

PLF98rxtslw6s is the published example on the playlist endpoint. The id is the list parameter in the playlist URL. In https://www.youtube.com/playlist?list=PLF98rxtslw6s it is everything after list=. A watch URL that carries &list=... holds the same id. There is no YouTube credential in the request. The only key is the Fetchproof key in x-api-key.

What the official API asks for

The YouTube Data API can list a public playlist too. PlaylistItems: list takes a playlistId, returns at most 50 items per call, and hands back a nextPageToken for the next page. Each call costs 1 quota unit. Before the first call you need a Google account, a Cloud project with the YouTube Data API enabled, and a key. The API overview puts the default allocation at 10,000 units a day across most endpoints, and it notes that invalid requests use quota too.

A playlist item is not the whole video. Its fields cover the title, the position, the video id and the publish date. A video’s length lives on the video resource, so a list with durations is a second round of Videos: list calls in batches of ids. That is fine for one job. It is more setup than most scripts, n8n flows and agent tools want for “give me the videos in this list.”

The other route is a local scraper such as yt-dlp with --flat-playlist. That needs no key, and it runs on your own IP. On a laptop that is usually fine. On cloud IPs, YouTube’s bot checks tend to show up halfway through a batch job. The YouTube transcripts post covers that failure in detail.

What comes back

The field names below match the published schema and example for playlist. Titles and ids are placeholders, so the sample does not claim what any playlist holds today.

{
  "success": true,
  "credits_remaining": 99,
  "credits_charged": 1,
  "title": "<playlist title>",
  "owner": {
    "id": "UC<channel id>",
    "name": "<channel name>",
    "url": "https://www.youtube.com/@<handle>",
    "handle": "@<handle>"
  },
  "totalVideos": 3,
  "videos": [
    {
      "id": "<video id>",
      "title": "<video title>",
      "thumbnail": "https://i.ytimg.com/vi/<video id>/hqdefault.jpg",
      "url": "https://www.youtube.com/watch?v=<video id>",
      "lengthText": "3:14",
      "lengthSeconds": 194,
      "channel": {
        "title": "<uploader name>",
        "url": "https://www.youtube.com/@<uploader handle>"
      }
    }
  ],
  "continuationToken": null
}

videos is one page in playlist order. Each row has the watch url, the title, a thumbnail, and the length both as text (lengthText) and as a number of seconds (lengthSeconds). That number is the field that saves the second round of calls. channel on a row is the uploader of that video, which can differ from the playlist owner. A playlist can mix uploads from many channels.

totalVideos is the count YouTube shows on the playlist page. continuationToken is null when there is nothing after this page.

Paging to the end

When continuationToken is a string, send it back as the continuationToken query parameter along with the same playlist_id. Treat the token as opaque. Copy it as you got it, and URL-encode it when you build the query string:

TOKEN="<continuationToken from the previous response>"

curl -s -G "https://api.fetchproof.com/v1/youtube/playlist?playlist_id=PLF98rxtslw6s" \
  --data-urlencode "continuationToken=$TOKEN" \
  --header "x-api-key: $FETCHPROOF_API_KEY"

Read title, owner and totalVideos from the first page. On a continuation page those playlist-level fields can come back null, because that page is only the next slice of videos. Do not assume a fixed page size either. Keep going until the token is null, and stop there.

Python

The standard library is enough:

import csv
import json
import os
import urllib.parse
import urllib.request

playlist_id = "PLF98rxtslw6s"
token = None
videos = []
first = None

while True:
    url = f"https://api.fetchproof.com/v1/youtube/playlist?playlist_id={urllib.parse.quote(playlist_id)}"
    if token:
        url += "&continuationToken=" + urllib.parse.quote(token, safe="")
    request = urllib.request.Request(
        url,
        headers={"x-api-key": os.environ["FETCHPROOF_API_KEY"]},
    )
    with urllib.request.urlopen(request, timeout=60) as response:
        body = json.load(response)
    if first is None:
        first = body
    videos.extend(body["videos"])
    token = body.get("continuationToken")
    if not token:
        break

print(first["title"], "-", len(videos), "videos collected;", first["totalVideos"], "shown on the playlist")
total_seconds = sum(v["lengthSeconds"] or 0 for v in videos)
print("total length:", round(total_seconds / 3600, 1), "hours")

with open("playlist.csv", "w", newline="") as f:
    writer = csv.writer(f)
    writer.writerow(["position", "id", "title", "url", "length_seconds", "uploader"])
    for position, v in enumerate(videos, start=1):
        writer.writerow([position, v["id"], v["title"], v["url"], v["lengthSeconds"], v["channel"]["title"]])

urllib.parse.quote with safe="" encodes every reserved character in the token. urlopen raises on a status that is not successful, so a missing or private playlist stops the loop with an error rather than writing an empty CSV. The or 0 guards against a row whose length is null, which can happen for an entry YouTube shows without a duration.

Node

Node 18 and later include fetch:

const playlistId = "PLF98rxtslw6s";
const videos = [];
let token = null;
let first = null;

do {
  const endpoint = new URL(`https://api.fetchproof.com/v1/youtube/playlist?playlist_id=${playlistId}`);
  if (token) endpoint.searchParams.set("continuationToken", token);
  const response = await fetch(endpoint, {
    headers: { "x-api-key": process.env.FETCHPROOF_API_KEY },
  });
  if (!response.ok) {
    throw new Error(`YouTube playlist failed: HTTP ${response.status}`);
  }
  const body = await response.json();
  first ??= body;
  videos.push(...body.videos);
  token = body.continuationToken;
} while (token);

console.log(first.title, videos.length, "videos;", first.totalVideos, "shown on the playlist");
console.log(videos.map((v) => v.url).join("\n"));

searchParams.set encodes the token. The same request works from an n8n HTTP Request node with the x-api-key header, the setup the n8n post walks through. Use the node’s pagination option to send continuationToken from the last response and stop when it is empty. From an MCP client the tool name is youtube_playlist, and the server setup is in the MCP docs.

Finding the playlist id, and going past the row

If you have a channel and not a playlist, channel playlists lists the playlists a channel publishes, with their ids. If what you want is every upload on a channel rather than a curated list, channel videos is the direct call.

A playlist row is deliberately small. View counts, the description and the publish date are on the video endpoint, one call per video. The captions for a row are on transcript. A common pattern is to page the playlist once, then fetch details only for the videos you actually need. Every YouTube route is on the YouTube API page.

What a call costs

Each playlist page costs 1 credit by default, so a playlist is as many credits as it has pages. Errors, blocked or timed-out requests, invalid requests and cache hits cost nothing. A not-found or empty result is charged only where that operation’s published cost says so.

This operation publishes that 1-credit default and no separate not-found price. A playlist YouTube does not show, including a private one, is HTTP 404 with error set to not_found, and credits_charged on that body is 0. A request with no playlist_id is HTTP 400, an invalid request. The playlist page states the published cost. Read credits_charged on each body if you want to log spend.

New accounts get 100 free credits, with no card. Pack sizes and prices are on the pricing page. Freelance is $27 for 25,000 credits. Business is $297 for 500,000 credits. Credits are prepaid and do not expire. How that compares with a daily quota is in prepaid credits vs monthly subscriptions.

FAQ

Do I need a YouTube Data API key or a Google Cloud project?

No. The request carries only the Fetchproof key in x-api-key. There is no OAuth flow and no YouTube quota to track, because the call does not go through your Google project.

Can it read private or unlisted playlists?

A private playlist is not public, so it comes back as the HTTP 404 above. Watch Later is a private list tied to a signed-in account, and this call has no YouTube login. An unlisted playlist is readable by anyone with its id, the same way the link works in a logged-out browser.

Why is my video count lower than totalVideos?

totalVideos is the number YouTube prints on the playlist page. That figure can include entries YouTube does not list to a logged-out viewer, such as videos that have gone private or been removed. Count the rows you collected, and treat totalVideos as YouTube’s own label rather than a promise.

How do I know I reached the last page?

continuationToken is null on the last page. Do not stop because a page looks short, and do not guess the next token. Send back exactly the string you received, with the same playlist_id.

Try it with 100 free credits

Sign up with an email address, no card. Credits never expire. Errors, invalid requests and cache hits cost 0 credits, and each endpoint page lists exactly what it charges.