Reputation: 614
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.
Upvotes: 2
Views: 3762
Reputation: 2240
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 the part=contentDetails
. Save the value under items[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 is UU0vrmjhkmbCxYUGl8KNFxMA
. The API call is:
GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UU0vrmjhkmbCxYUGl8KNFxMA&key={YOUR_API_KEY}
Upvotes: 8