How do I list the user's uploaded videos in the V3 api?
-
listing the Channels / Playlists by using the mine parameter but I can't find the way to list the videos of a channel – efic1 Oct 17 '12 at 08:34
2 Answers
If you are using the client then Greg's answer is correct. To do the same thing with basic requests you make the following 2 requests:
GET https://www.googleapis.com/youtube/v3/channels
with parameters:
part=contentDetails mine=true key={YOUR_API_KEY}
and header:
Authorization: Bearer {Your access token}
From this you will get a JSON response like so:
{ "kind": "youtube#channelListResponse", "etag": "\"some-string\"", "pageInfo": { "totalResults": 1, "resultsPerPage": 1 }, "items": [ { "id": "some-id", "kind": "youtube#channel", "etag": "\"another-string\"", "contentDetails": { "relatedPlaylists": { "likes": "channel-id-for-your-likes", "favorites": "channel-id-for-your-favorites", "uploads": "channel-id-for-your-uploads", "watchHistory": "channel-id-for-your-watch-history", "watchLater": "channel-id-for-your-watch-later" } } } ] }
From this you want to parse out the "uploads" channel-id.
GET https://www.googleapis.com/youtube/v3/playlistItems
with parameters:
part=snippet maxResults=50 id={YOUR_UPLOAD_PLAYLIST_ID} key={YOUR_API_KEY}
and headers:
Authorization: Bearer {YOUR_TOKEN}
From this you will receive a JSON response like the following:
{ "kind": "youtube#playlistItemListResponse", "etag": "\"some-string\"", "pageInfo": { "totalResults": 1, "resultsPerPage": 50 }, "items": [ { "id": "some-id", "kind": "youtube#playlistItem", "etag": "\"another-string\"", "snippet": { "publishedAt": "some-date", "channelId": "the-channel-id", "title": "video-title", "thumbnails": { "default": { "url": "thumbnail-address" }, "medium": { "url": "thumbnail-address" }, "high": { "url": "thumbnail-address" } }, "playlistId": "upload-playlist-id", "position": 0, "resourceId": { "kind": "youtube#video", "videoId": "the-videos-id" } } } ] }
With this method you should be able to get the info using any language or even just curl. If you want more than the first 50 results, then you will have to do multiple queries using the second request and pass in page requests. More on this can be read at: http://developers.google.com/youtube/v3/docs/playlistItems/list

- 6,041
- 4
- 27
- 38

- 1,918
- 1
- 18
- 18
-
-
@PratikCJoshi Using https://developers.google.com/youtube/v3/docs/channels/list @ the bottom look for the demo. I'm passing: https://www.diigo.com/item/image/5enzo/a9ey yielding "uploads": "UUhS0SPpEqGMGRim7mebedPg". @ https://developers.google.com/youtube/v3/docs/playlistItems/list where I'm doing this: https://www.diigo.com/item/image/5enzo/up3b ... The lame thing is that content length isn't being included. You can find that with contentDetails on /videos expressed like "duration": "PT7M18S"; I wish it was included without this insane per-video querying. – kristopolous Oct 04 '15 at 01:11
-
As far as a coherent implementation, I plan to upgrade https://github.com/kristopolous/ytmix/blob/master/import/parse.js from the v2 to the v3 (because blah, I have to). So by the time you click this, it will be v3. – kristopolous Oct 04 '15 at 01:16
-
Thank you for this detailed answer; it really helped me out! In case it's helpful, here is the documentation for the "uploads" channel ID: https://developers.google.com/youtube/v3/docs/channels#contentDetails.relatedPlaylists.uploads – Alexander May 22 '19 at 17:07
The first step is getting the channel id for that user. We can do this with request to the Channels
service. Here's a JS example.
var request = gapi.client.youtube.channels.list({
// mine: true indicates that we want to retrieve the channel for the authenticated user.
mine: true,
part: 'contentDetails'
});
request.execute(function(response) {
playlistId = response.result.channels[0].contentDetails.uploads;
});
Once we get the playlist id we can use that to query for the list of uploaded videos from the PlaylistItems
service.
var request = gapi.client.youtube.playlistItems.list({
id: playlistId,
part: 'snippet',
});
request.execute(function(response) {
// Go through response.result.playlistItems to view list of uploaded videos.
});

- 6,041
- 4
- 27
- 38

- 2,291
- 15
- 16
-
For me the `.list` method does not return. I have two simple logs, right before and after calling the method, the first executes, the second does not. Any ideas? – Julian F. Weinert May 16 '14 at 14:01