Simple wrapper of youtube api for getting info about videos also ones in playlist.
$ npm i -S qm-yt-api
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..."
// }
// ],
// };
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.
For all encounter API error messages the module throws an error.
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.
Due to access via api key getting private video information is limitted.
MIT © qaraluch