Retrieve YouTube Video Details using JavaScript

Retrieve Youtube Video Details using JavaScript

Use this code to retrieve Youtube video details using JavaScript. This script use YouTube API v2.0 with the support of jQuery. Also I have created a small tool that you can generate all required information of a YouTube video. You can access demo and generator here:

Using this script you can get YouTube video title, Uploader of the video and link to user profile, video category, video published date, video duration in seconds (or you can change it to minutes or hours), how many users have viewed this video, video rating, number of rators, favourite count, how many people likes and dislikes the video, number of comments, YouTube video description and supporting thumbnails with the embedded video.

JavaScript to get YouTube video info

This is the part that do the trick.

Using jQuery we assign variable values into html element as it’s contents. You must update var vidid = "HSvoF8IfzRY"; and replace HSvoF8IfzRY with video id of your video. You can find video id from the YouTube video url.

How to get YouTube video ID

Highlighted part is the Video ID

This is the HTML and CSS part of the code. You can change style here.

UPDATE: As Ryan requested you can get the PHP version of the same snippet here:
How to get YouTube Video Info with PHP
Comments
  1. Ryan

    with simple comments to explain the action.If possible add related videos too.

  2. Ryan

    Thank you. This is exactly what I was looking for. There are many scripts to retrieve youtube info but all of them looks like exactly the same like copied from same source or something. None of them were complete as they are missing some details like comments count. Is there anyway you can provide php code for same tool? I’m doing kind of a project right now and I need to do it in php but without using json. If you can please do another article as soon as possible. It’s a bit of a emergency.