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:/
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(); }
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}
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.
Following method to fetch YouTube title, description and tags
First of all create Google API key
https://console.cloud.google.com/home/dashboard
go to credentials - create API key
https://console.cloud.google.com/apis/credentials?folder=&organizationId=&project=
enable YouTube API
https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=
download postman software to POST data on google server YouTube API
https://www.googleapis.com/youtube/v3/videos?key=your-key&fields=items(snippet(title,description,tags))&part=snippet&id=youtube-id