How do I obtain a list of all videos in a channel

2019-01-20 12:04发布

问题:

I'm using the YouTube API 3 for a client and am not getting all current videos.

The API Explorer has 4 results: https://www.googleapis.com/youtube/v3/search?part=id%2C+snippet&channelId=UCwB4tpXCMWi-bw5HpMlY6Bg&maxResults=50&key={YOUR_API_KEY}

And here is the client YouTube page: http://www.youtube.com/user/goldensteinart/videos which has 7 videos. They must all be public or they wouldn't appear on the page, right?

What am I missing?

回答1:

The API call that you should make if you want to get the videos in a channel is a youtube.playlistItems.list() with the playlistId of the "uploads" playlist for the channel. (This usually stars with UU..., but that's an implementation detail that might change in the future.

Here's an example of the call in the API Explorer.

Getting the same data via a search operation isn't guaranteed to return everything; the search index isn't a replacement for the backend data that you can obtain via the youtube.playlistItems.list() call. It's very much the same point raised in this blog post (though the focus there is on v2).

We just posted a YouTube video talking about how to get the videos in a channel, and there's samples illustrates how to make the actual API calls from your code in the documentation.