0

I'm trying to get the list of all videos in a channel, using the playlistItems list to get all the videos by passing the playlistId. Example -

Get the ID of your channel's uploads playlist using the channels.list API call: GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id={YOUR_CHANNEL_ID}&key={YOUR_API_KEY}

Get the videos from the uploads playlist using the playlistItems.list call: GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId={YOUR_PLAYLIST_ID}&key={YOUR_API_KEY}

And I'm using the next page token to get to the pages and loop through till I keep getting the next page token.

But I noticed that, this is very inconsistent. The above doesn't return all the videos of the channel. All the missing videos are available on YouTube and also return valid data when using the VideosList end point passing in their videoIds.

Till now I have noticed the same videos are missing every time and they were available in the past. Is this a known issue with the YouTube APIs ?

And is there any other way to get all the videos of channels of all statuses (public, private, unlisted). Even large channels which can have 50k+ videos.

User3120
  • 20
  • 6

1 Answers1

1
  1. https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=3&playlistId={YOUR_PLAYLIST_ID}&key={YOUR_API_KEY} won't return all videos because of maxResults=3 you can increase maxResults up to 50. And after having get the first 50 results (if there are more than 50) a new newPageToken is provided which you have to use by appending to the previous URL &pageToken=THE_NEW_PAGE_TOKEN and so on. If it doesn't work anyway the next point may interest you.

  2. It is known that YouTube playlists are limited to 20 000 videos so recovering videos from channels with more 50 000 videos won't work as usual and there isn't any YouTube Data API v3 endpoint which will recovers all videos of these channels. However as you browse the Videos tab of a YouTube channel with more than 50 000 videos you will discover all the missing videos from the PlayList method. You can automatize this at a low level by using curl for instance. Here you may find a Python code doing exactly this: https://stackoverflow.com/a/69121286/7123660

Benjamin Loison
  • 880
  • 1
  • 6
  • 17
  • Hi thanks for the response. I have updated my answer I was actually using maxResults=50 and the next page tokens to loop through all the videos but was still facing the same issues. – User3120 Oct 20 '21 at 06:28
  • For your solution #2, it won't give private and unlisted videos. – User3120 Oct 20 '21 at 06:41
  • If the channel is yours, you can adapt my algorithm to recover also private and unlisted videos from YouTube Studio interface for instance. If the channel isn't yours there isn't any way to list private and unlisted videos otherwise it would be a privacy issue. – Benjamin Loison Oct 20 '21 at 10:41