Skip to content

A YouTube API wrapper for Node.JS that caches results to limit quota usage.

Notifications You must be signed in to change notification settings

SEBv15/youtube-cached-api

Repository files navigation

youtube-cached-api

A YouTube API wrapper for Node.JS that caches results to limit quota usage.

This library saves ALL request parameters and responses so it will generate a lot of data very quickly. Therefore it should only be used in applications were the same videos/channels/etc are accessed most of the time.

Also since it is cached, search results will not show the newest videos, but the content it received when a request was made for the first time. (Except when the forceUpdate flag is set).

Installation

To install the library use

npm i youtube-cached-api --save

Usage

Go to the Google Developer API Console to get an API token

var youtube = require("youtube-cached-api")
youtube.connect("mongodb://localhost:27017")
youtube.token("your API token")

youtube.on("connection", async () => {
    // search for despacito
    var despacitoSearch = new youtube.Search({
        q: "Despacito"
    })
    console.log(despacitoSearch.newItems)

    // Get 5 more search results
    await despacitoSearch.next(5)
    console.log(despacitoSearch.newItems)
})

About

A YouTube API wrapper for Node.JS that caches results to limit quota usage.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published