This API used for fetching data from YouTube like Video details, channel details, list of popular videos. This also helps in getting embed player HTML with various configuration.
##How to use
- Get the Google Developer Key from Google Developer Console. Follow this link. https://developers.google.com/youtube/registering_an_application
- Include the JS file in your head section
- Initilize API with Google developer key by writing this line
youtube.init(YOUR_KEY);
###Getting Video Data
var data = youtube.getVideoData(YOUTUBE_VIDEO_URL);
This method returns JSON array of video data. This are the elements which are retrieved
data.id
data.publishedAt
data.channelId
data.title
data.description
data.thumbnails.default.url
data.thumbnails.default.width
data.thumbnails.default.height
data.channelTitle
data.tags[]
data.categoryId
data.liveBroadcastContent
data.defaultAudioLanguage
data.videoDuration
data.dimension
data.defination
data.licensedContent
data.uploadStatus
data.privacyStatus
data.license
data.embeddable
data.publicStatusViewable
data.viewCount
data.likeCount
data.dislikeCount
data.favouriteCount
data.commentCount
youtube.getEmbedPlayer(YOUTUBE_VIDEO_URL, [isDisplaySuggestedVideo = true, isDisplayPlayerControls = true, isDisplayPlayerActions = true, isEnablePrivacyMode = false, playerWidth = 630, playerHeight = 315]):
Here's only first argument is mandatory, others is optional
isDisplaySuggestedVideo : default argument set to true, for displaying other videos on end
isDisplayPlayerControls : default argument set to true, for displaying player controls like play, pause, volume, seek bar
isDisplayPlayerActions : default argument set to true, for displaying video title and share option on load
isEnablePrivacyMode : default argument set to false, if set to true - YouTube doesn't store information of user until video played
playerWidth : default argument set to 560, Width of player
playerHeight : default argument set to 315, Height of player
youtube.getEmbedVideoUrl(YOUTUBE_VIDEO_URL);
Visit other projects at http://dhruvpatel.net