1.1.8 • Published 4 years ago
my-yt-api v1.1.8
You look for a simple youtube api? Here is it ;D
Version 1.1.8
warn: Security global.MY_YT_API_KEY returns used API_KEY; Do not send the res json to third-party! -> json includes sensitiv data (e.g req_master)
Api docs, News/Updates, support... here
Table of Contents
Require the npm's modules
const ytube = require('my-yt-api');
Create yt client for getting access to ytb's db
const client = new ytube.Client({
API_KEY: "YOUR-API-KEY"
});
Methodes
searching for youtube video
client.searchVideo($string, function(err, res) => {
//check if there is an error
if(err) return console.error(err);
//check if there are results
if(res){
/*
this is an example of handling the result!
the result is json and there are a lot of properties you can use..
the properties are shown below
*/
console.log(res[0].url);
}
}, {optional_flags});
Properties
/*
returns number of results (Int)
range 0-50;
*/
res.length
/*
returns video url (string)
e.g https://www.youtube.com/watch?v=dQw4w9WgXcQ
*/
res[0].url
//res[0].shortURL returns the 'short URL'
/*
returns videos title (string)
*/
res[0].title
/*
returns videos description (string)
*/
res[0].description
/*
returns videos id (string)
e.g dQw4w9WgXcQ
*/
res[0].id
/*
returns the >>default<< thumbnail url (string)
[format == JPG}
*/
res[0].thumbnail
/*
return thumbnail types
-default
-medium
-high
*/
//URL (jpg)
res[0].thumbnails.<type>.url
//width in px
res[0].thumbnails.<type>.width
//height in px
res[0].thumbnails.<type>.height
/*
returns used params... no params returns "default"
*/
res[0].params
/*
returns the request url to youtubes servers
*/
res[0].req_url
/*
returns used the api_key
*/
res[0].req_master
Flags
{
RESULT_LIMIT: 5, //1-50;
CHANNEL_ID: "default", //e.g : UCuAXFkgsw1L7xaCfnd5JJOw;
VIDEO_TYPE: "default", //completed, live, upcoming;
ORDER: "default", //date, rating, relevance, title, videoCount, viewCount;
SAFE_SEARCH: "default", //moderate, none, strict;
VIDEO_QUALITY: "default", //any, high, standard;
VIDEO_DIMENSION: "default", //2d, 3d;
VIDEO_DURATION: "default", //*any*, *long*(vid needs to be longer then 20min), *medium*(4min-20min), *short*(0.1sek-4min);
EMBEDDABLE: "default", //any, true;
VIDEO_LICENSE: "default", //any, creativeCommon, youtube;
VIDEO_LENGTH_TYPE: "default" //any, episode, movie;
}
There will be some updates soon ;)