Getting a list of videos from a YouTube channel using JSON

15,050

Once you get the parsed object, you can iterate through it like:

$.getJSON('https://gdata.youtube.com/feeds/api/videos?q=googledevelopers&max-re‌​sults=5&v=2&alt=jsonc&orderby=published', function(data) {
    console.log(data);
    for(var i=0; i<data.data.items.length; i++) {
       console.log(data.data.items[i].title); // title
       console.log(data.data.items[i].description); // description
    }
});
Share:
15,050
Sam
Author by

Sam

studying computer science!

Updated on June 04, 2022

Comments

  • Sam
    Sam almost 2 years

    I am attempting to list the 5 most recent videos (title, updated, thumbnail (hqDefault)) from a channel. I have the data in JSON format, but despite looking at several guides I can not seem to parse it. Any ideas? Can use Javascript or jQuery.

    Here's the URL: https://gdata.youtube.com/feeds/api/videos?q=googledevelopers&max-results=5&v=2&alt=jsonc&orderby=published

    FWIW here is what I have so far (Disregard HTML formatting)

        $.getJSON('https://gdata.youtube.com/feeds/api/videos?q=googledevelopers&max-results=5&v=2&alt=jsonc&orderby=published', function(data) {
        var output="<ul>";
        for (var i in data.data.items) {
            output+="<li>" + data.data.items[i].title + "</li>";
        }
        document.getElementById("videos").innerHTML=output;