Skip to content Skip to sidebar Skip to footer

How To Retrieve A YouTube Video's Tags With YouTube V3 API?

I want to retrieve the tags for a specific YouTube video using v3 of the YouTube API. I'm able to retrieve a video with this request to the search endpoint, https://www.googleapis.

Solution 1:

According to https://developers.google.com/youtube/v3/docs/videos/list it appears that the latest version of the YouTube API now returns tags:

https://www.googleapis.com/youtube/v3/videos?key={API-key}&fields=items(snippet(title,description,tags))&part=snippet&id={video_id}

Solution 2:

Unfortunately, at present you can only get videos with tags when you authenticate yourself as the owner of the channel. Searching for tags used to work, but is broken in the current V2 implementation.


Solution 3:


Solution 4:

I retrived video tags like this in my javascript , you can see - here

function getYouTubeTags() {

var q = document.getElementById("query").value;

VID_REGEX = /(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/;

var vidid = q.match(VID_REGEX)[1];
var key = "...";

var newrequest = new XMLHttpRequest();
newrequest.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {

        var data = JSON.parse(this.responseText).items[0].snippet;
        //   document.getElementById("keyword").innerHTML = data.tags;
        document.getElementById("titlen").innerHTML = data.title;

        var i;
        var cell4 = document.getElementById('tgs');
        for (i = 0; i < data.tags.length; i++) {

            var element3 = document.createElement("input");
            element3.type = "button";
            element3.name = "add";
            element3.value = data.tags[i];
            element3.className = "btn btn-danger";
            cell4.appendChild(element3);

            /*to set Image*/
            document.getElementById("myImg").src = "https://img.youtube.com/vi/" + vidid + "/hqdefault.jpg";

        }

    }
};

newrequest.open('GET', "https://www.googleapis.com/youtube/v3/videos?id=" + vidid + "&key=" + key + "&fields=items(snippet(title,description,tags))&part=snippet", true);

newrequest.send(); }

Post a Comment for "How To Retrieve A YouTube Video's Tags With YouTube V3 API?"