New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ytjs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ytjs

Youtube API v3 Universal Javascript Library for nodeJS, AMD and browser which provides easy API

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
4
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

YTjs

Youtube API v3 Universal Javascript Library for nodeJS, AMD and browser which provides easy API

No Jquery needed.

How to get Youtube API Key

Click here

Node JS

Example

var youtube = require('ytjs')("API KEY");

youtube.getdata({ videoId: "TlgqWeuhJj4"},function(err, result){
    if(err) {
      console.log(err);
      return false;
    }
    console.log(result);
});

Browser

include yt.js

<script type="text/javascript" src="yt.js" ></script>

Initalize the library and get Data

var youtube  = $youtube("API KEY");

 youtube.getdata({ videoId: "TlgqWeuhJj4" },function(err, result){
    if(err) {
      console.log(err);
      return false;
    }
    console.log(result);
 });
        
youtube.getdata({ videoId: "PMr2NRPdpH4"}, function(err, result){
    if(err) {
      console.log(err);
      return false;
    }
    console.log(result);
});

Methods Available

  • getdata
  • search
  • getComments
  • getRelatedVideos

get video data (getdata)

youtube.getdata({ videoId: "TlgqWeuhJj4" },function(err, result){
    if(err) {
      console.log(err);
      return false;
    }
    console.log(result);
 });
youtube.search({keyword: "rihanna love", fullResults: 1, order: "relevance"}, function(err, data){
    if(err) {
      console.log(err);
      return false;
    }
    console.log(data);
});

Comments (getComments)

youtube.getComments({videoId: "PMr2NRPdpH4"}, function(err, data){
    if(err) {
      console.log(err);
      return false;
    }
    console.log(data);
});   
youtube.getRelatedVideos({videoId: "PMr2NRPdpH4"}, function(err, data){
    if(err) {
      console.log(err);
      return false;
    }
    console.log(data);
});       

Options

getdata

  • videoId : youtube video id
  • part: "snippet,statistics,contentDetails" // you can pass either of three orcombination or all

output format (getdata)

You can get wide variety of data from getdata method and always youtube original data can be referred in raw

"title":
"description":
"rating":
"views":"",
"publishedAt":
"dthumbnail":
"mthumbnail":
"hthumbnail":
"sthumbnail":
"categoryId":
"channelTitle":
"videoId":"",
"duration":
"mins":
"hr":
"secs":
"dimension":
definition":
caption":
licensedContent":
"viewCount":
"likeCount":
"dislikeCount":
"favoriteCount":
"commentCount":
"kind":
"channelId":
"thumbnails":{}
"tags":{}
"liveBroadcastContent":"none"
"localized":{}
"projection":
"raw":{}
  • keyword : keyword for search
  • order: "relevance" // date, rating, viewCount, videoCount, title
  • type : "basic" // "detailed" will provide additional information for each search video
  • navigate : "next" // would render next set of results as youtube only allows 50 videos at a time

You can get wide variety of data from search method. Results of search will be returned in videos array and always youtube original data can be referred in raw

"videos" : []
nextPageToken:
prevPageToken:
kind:

comments

youtube.getComments({videoId: "PMr2NRPdpH4"}, function(err, data){
    if(err) {
      console.log(err);
      return false;
    }
    console.log(data);
    nextComments();
});

// next set of comments
function nextComments() {
    youtube.getComments({videoId: "PMr2NRPdpH4", navigate: "next"}, function(err, data){
        if(err) {
          console.log(err);
          return false;
        }
        console.log(data);
    });
}

output format (getComments)

You can get wide variety of data from getComments method. Results of comments will be returned in items array and always youtube original data can be referred in raw

items array item usually have different values such as textDisplay, authorDisplayName, authorProfileImageUrl, likeCount etc

items : []
nextPageToken:
prevPageToken:
resultsPerPage:
raw:
youtube.getRelatedVideos({videoId: "PMr2NRPdpH4"}, function(err, data){
    if(err) {
      console.log(err);
      return false;
    }
    console.log(data);
});    

output format (getRelatedVideos)

You can get wide variety of data from getRelatedVideos method. Results of related videos will be returned in videos array and always youtube original data can be referred in raw

"videos" : []
nextPageToken:
prevPageToken:
kind:

debug mode

Debug mode will print details to your console. you can enable debug mode during intialization by passing true

var youtube  = $youtube("API KEY", true);

Implemented Features

[ x ] get Video Data

[ x ] search for videos

[ x ] get Comments

[ x ] npm module

[ x ] related videos

Upcoming Plan

[ ] Please open an issue

Keywords

ytjs

FAQs

Package last updated on 27 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts