Menu

5 YouTube Data API traps I hit building a playlist manager
📰

5 YouTube Data API traps I hit building a playlist manager

DEV Community: angular·Sam Wootton·about 2 hours ago
#AsIWrNqS
#devtoangular#devto#dev#playlist#playlists
Long article (458 words) — no AI summary yet.
Reading 0:00
15s threshold

I built TidyList, a web app for cleaning up big YouTube playlists, on the YouTube Data API v3. Most of it behaved as documented. These five didn't, and each one cost me.

1. Paging never ends

You page through a playlist with nextPageToken , and the docs suggest you stop when it's missing. On a 3,404-video playlist, YouTube got past the last page and kept going: every response came back with items: [] and a nextPageToken equal to the one I'd just sent. Forever. My loop ran past 500 pages before I noticed, at one unit of my daily API quota per page.

The fix is to keep every token you've requested and stop as soon as one repeats. While you're there, leave pageToken out completely on the first request. Sending it as an empty string gave me 404s on some playlists.

2. Liked videos is just "LL"

channels.list?part=contentDetails&mine=true gives you relatedPlaylists , with your uploads and your likes. Uploads comes back as UU plus your channel ID, so it's tempting to build the likes ID the same way. Don't.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.