0.2.7 • Published 6 years ago

yt-api v0.2.7

Weekly downloads
30
License
MIT
Repository
-
Last release
6 years ago

Welcome to the yt-api a light weight, easy, and super fast way of interacting with the YouTube Data API v3.

Setup

To use the api you need a api key from google and you can get that here Once you have created the api key you need to enable the Youtube Data API v3 by clicking on the libraries tab and clicking on the Youtube Data API v3 then click on enable and your almost done!

Need support?

You can join the official support discord here

Defining the api

const api = require("yt-api");
const API = new api.Client("PASTE_API_KEY_HERE");

Getting video info

API.getVideoByID("mj9KRKSvdbk" /*This must be a valid video id or else it will reject the promise*/).then(i => {
    console.log("Here is the url: "+i.url);
}).catch(e => console.error(e));

//Returns Promise<VideoInfo>

Getting playlists

API.getPlaylist("PLxYB-Vuz54ip2mYZrZvit7l6kHL5gGHZI").then(p => {
    console.log(`
Playlist title: ${p.playlistTitle}
Playlist thumbnail: ${p.playlistThumbnail}
Playlist creator: ${p.playlistCreator}
Playlist id: ${p.playlistId}
Playlist videos: ${p.playlistVideos.map(v=>`${v.title} | ${v.url}`).join('\n')}
    `);
});

Searching for a video

API.searchForVideo("H.A.Y ncs").then(i => {
    console.log("Here is the url: "+i.url);
}).catch(e => console.error(e));

//Returns Promise<SearchedVideoInfo>
/*NOTE: You can use the getVideoByID function to get more info about this video*/

Searching for multiple videos

API.searchForVideos("H.A.Y ncs").then(i => {
    console.log("Here is the first result's video url "+i[0].url)
}).catch(e => console.error(e));

//Returns Promise<SearchedVideoInfo> as a array
0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.1

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago