user1698229
user1698229

Reputation: 111

How can I get a list of videos from a playlist in an auto-generated YouTube channel via the API?

YouTube has introduced auto-generated channels, for example http://www.youtube.com/channel/UCH-BBvNWh1CONPAjpeocGcw. From the channelId, I can use the API to retrieve its associated playlists:

GET https://www.googleapis.com/youtube/v3/playlists?part=contentDetails&channelId=UCH-BBvNWh1CONPAjpeocGcw&key={YOUR_API_KEY}

gets, in part:

"items": [
{
"kind": "youtube#playlist",
"etag": "\"GbgM9_0DKhSLzW6BxAmfOJZH9RI/q_Rxfox9sHfH_r9g_LimnQeVsyU\"",
"id": "ALNb4maWNoT6RXC29sfG8iREznyAb9tqqJ",
"contentDetails": {
    "itemCount": 95
}
},......

Each playlist has an id and an itemCount. When I use the playlistId, I get no items back:

GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&id=ALNb4maWNoT6RXC29sfG8iREznyAb9tqqJ&key={YOUR_API_KEY}

gets me

{
"kind": "youtube#playlistItemListResponse",
"etag": "\"GbgM9_0DKhSLzW6BxAmfOJZH9RI/3cxjRXf86G9z5Bg7rup3QfCgrxM\"",
"pageInfo": {
    "totalResults": 0,
    "resultsPerPage": 5
},
"items": [
]
}

Am I missing a step?

Upvotes: 2

Views: 3973

Answers (1)

user1698229
user1698229

Reputation: 111

Solved my own problem. The playlistId should be the "playlistId" parameter, not "id".

GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=ALNb4maWNoT6RXC29sfG8iREznyAb9tqqJ&key={YOUR_API_KEY}

Upvotes: 4

Related Questions