How to find videos using the YouTube API based on a channel ID

1.6k views Asked by At

So I am playing around with the YouTube API v3 for a web app I am building. I've got the basics down, but I am searching through documentation trying to find a way to filter a returned video list based on a channelID. However this doesn't seem to be possible. Is there way to write a request similar to this pseudocode below:

   https://www.googleapis.com/youtube/v3/videos?part=snippet&

   // and a second value that would imply with channelID=UCn8zNIfYAQNdrFRrr8oibKw

This seems like a logical function to have in the API. However, I can't seem to find any name/value pair in the documentation to support this theory.

The closest I can seem to find is the onBehalfOfContentOwner name/value pair for the video.list request (but it requires me to be the uploader of the video?) as outlined here

Anyways if someone can answer definitively if this is possible (if yes a link to docs or example I can use) as I've poured over docs looking for this functionality with no luck. Any help would be much appreciated!

2

There are 2 answers

0
Als On

Your link refers to a video search.

1) First, you need to retrieve the channel info for the channelID (e.g. UCn8zNIfYAQNdrFRrr8oibKw).

See: https://developers.google.com/youtube/v3/docs/channels
Get the part:

"contentDetails": { "relatedPlaylists": { "likes": string, "favorites": string, "uploads": string, "watchHistory": string, "watchLater": string }

2) Then use the "uploads": string, to retrieve the videos, being the user uploaded videos, which is a playlist.

For retrieving playlists see: https://developers.google.com/youtube/v3/docs/playlists .

0
emcas88 On

Use the api call search.list, for example:

GET https://www.googleapis.com/youtube/v3/search?channelId=ASADKAHWSDA&type=video&key={YOUR_API_KEY}

in the query parameters specified the resource type = video because you want the videos of this channel. As cited here https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list

The type parameter restricts a search query to only retrieve a particular type of resource. The value is a comma-separated list of resource types. (string)

The resource can be anything a video, playlist, subscriber, etc. Hope this help.