I got the problem when trying to get all of videos from a chanel.
Here is the chanel:
http://www.youtube.com/channel/UC0vrmjhkmbCxYUGl8KNFxMA
I try to get Playlist with my API key but it returned an empty array:
https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UC0vrmjhkmbCxYUGl8KNFxMA&key=
Please help me.
2
votes
1 Answers
8
votes
The channelId parameter does not specify a channel to return videos for. Think of it as a "filter" to only show playlists from a specific channel.
Instead, do this:
Make a
channel.list()
API call with your channel ID and thepart=contentDetails
. Save the value underitems[0][contentDetails][relatedPlaylists][uploads]
. Example:GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=UC0vrmjhkmbCxYUGl8KNFxMA&key={YOUR_API_KEY}
Make a
playlistItems.list()
API call with the value retrieved in the ID field. In your specific case, this isUU0vrmjhkmbCxYUGl8KNFxMA
. The API call is:GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UU0vrmjhkmbCxYUGl8KNFxMA&key={YOUR_API_KEY}