Skip to content
This repository has been archived by the owner on Dec 17, 2019. It is now read-only.

qaraluch/qm-yt-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo-qm

qm-yt-api (DEPRECATED) npm version code style: prettier

Simple wrapper of youtube api for getting info about videos also ones in playlist.

Installation

$ npm i -S qm-yt-api

Usage

All module's functions returns promise object.

import ytAPI from "qm-yt-api";

// ...

const videoInfo = await ytAPI.getVideoInfo(key, videoId);
// =>
// {
//   id: "8CrOL-ydFMI",
//   title: "This Is Water ... "
// }

// or
const videos = await ytAPI.getVideosInfoFromPlaylist(key, playlistId);
// =>
// {
//   playlistName: "...",
//   playlistId: "PL14-...",
//   itemsNumber: 2,
//   askDate": "Tue Oct 31 2017 09:19:50 GMT+0100 (STD)",
//   videos: [
//     {
//       position: 0,
//       id: "8CrOL-ydFMI",
//       publishedAt: "2017-10-21T16:44:15.000Z",
//       title:
//         "This Is Water ..."
//     },
//     {
//       position: 1,
//       id: "RnGvWTRQ9j4",
//       publishedAt: "2017-10-21T16:44:59.000Z",
//       title: "Everyday Virtue..."
//     }
//   ],
// };

Options

There's possibility to get raw youtube api response. All you need is set additional option:

const options = { rawApiData: true }; //default: false
const videoInfo = await ytAPI.getVideoInfo(apiKey, videoId, options, apiOptions)

You can modify api request by passing apiOptions argument. Default used are:

const apiOptions = {
  part: "snippet, contentDetails"
};

See additional options in Google documentation.

YT API Errors:

For all encounter API error messages the module throws an error.

Tests

Tests are made against real YT data, so for performing testing you need working google apikey and put it to ./test/key.json file. Use .key-tmeplate.json as reference.

Limitations

Due to access via api key getting private video information is limitted.

Credits

License

MIT © qaraluch

About

(DEPRECATED) Simple wrapper of youtube api for getting info about videos also ones in playlist.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published