Youtube api v3 Get list of user's videos

With Youtube api v2, there's easy way to get videos. Just send a query like this:

http://gdata.youtube.com/feeds/mobile/videos?max-results=5&alt=rss&orderby=published&author=OneDirectionVEVO

The Youtube api v2 also has an interactive demo page for building query: http://gdata.youtube.com/demo/index.html

With Youtube api v3, I don't know the corresponding way. Please point me the way with api v3.

Thank you!


The channels#list method will return a JSON with some information about the channel, including the playlist ID for the "uploads" playlist:

https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=OneDirectionVEVO&key={YOUR_API_KEY}

With the playlist ID you can get the videos with the playlistItems#list method:

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

You can test those at the end of the documentation pages.


This should do it. This code just gets and outputs the title but you can get any details you want

// Get Uploads Playlist
$.get(
   "https://www.googleapis.com/youtube/v3/channels",{
   part : 'contentDetails', 
   forUsername : 'USER_CHANNEL_NAME',
   key: 'YOUR_API_KEY'},
   function(data) {
      $.each( data.items, function( i, item ) {
          pid = item.contentDetails.relatedPlaylists.uploads;
          getVids(pid);
      });
  }
);

//Get Videos
function getVids(pid){
    $.get(
        "https://www.googleapis.com/youtube/v3/playlistItems",{
        part : 'snippet', 
        maxResults : 20,
        playlistId : pid,
        key: 'YOUR_API_KEY'},
        function(data) {
            var results;
            $.each( data.items, function( i, item ) {
                results = '<li>'+ item.snippet.title +'</li>';
                $('#results').append(results);
            });
        }
    );
}


<!--In your HTML -->
<ul id="results"></ul>

If quota cost is a consideration, it may be beneficial to follow this simple algorithm.

First grab the data from https://www.youtube.com/feeds/videos.xml?channel_id=... This is a simple XML feed which will give you the video ID's, but you cannot specify further 'parts' (stats, etc).

Using the video ID's from that list, do a query on the /videos API endpoint which allows for a comma-separated-list of video ID's which should only result in 1 quota cost, plus 0-2 for any additional part parameters. As @chrismacp points out, using the /search endpoint is simpler but has a quota cost of 100, which can add up quickly.

There is a resource consideration here (cpu, memory, etc) as you are making a second call, but I believe in many scenarios this can be a useful method.