npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

youtube-query

v0.0.2

Published

Node Package useful to query Youtube data

Readme

Youtube Query

youtube-query is a library to easily query public information on Youtube, like popular videos, public playlists, etc.

This library tries to greatly simplify the retrieval of public Youtube graph data, so it can be easily used in robots, utilities, webapps, etc.

To install, run:

    $ npm install youtube-query

To use this library you'll need a Youtube (Data API)[https://developers.google.com/youtube/v3/] key.

#Examples

Retrieve videos

    const Youtube = require('youtube-query')
    const client = new Youtube(youAPISecretKey)

    // get the lastest popular videos
    client.videos.fetch((err, videos) => {
        ...
    })

    // We can also apply filters to retrieved videos.
    // See https://developers.google.com/youtube/v3/docs/videos/list 
    const mxVideos = client.videos.filter({regionCode: 'MX'})
    mxVideos.fetch((err, videos) => {
        console.log(videos)
    })

    // we can also fetch the next page of videos
    mxVideos.next((err, videos) => {
        console.log('Next page fetched', videos)
    })

Searching

    const Youtube = require('youtube-query')
    const APIKey = 'secret-key'
    const client = new Youtube(APIKey)

    // Search Youtube
    // (`fetch` and `next` can optionally accepts a page size as first argument)
    client.search('funny videos').fetch(10, (err, videos) => {
        // once resolved, fetch the next 20 funny videos
        videos.next(20, (err, nextVideos) => {
            // ...
        })
    })

    // Only perform a playlist search
    housePlaylists = client.search('house music').filter({type: 'playlist'})
    housePlaylists.fetch((err, playlists) => {
        ...
    })

API

Youtube class has the videos, search, and playlists properties. These all properties are inherited from a base Resource class which is an extended array.

Resource class

All resources available through Youtube class are inherited from this class. So, in all of them the following methods and properties are available:

maxResults: integer

The default number of resources to return in a request. Max posible value is 50.

filter: fn(object)

Updates the resource list filters. This method does not replaces the current filters with new received one. Instead it extends the currently existing filters.

filters: object

Defined filters for the resource.

fetch: fn([pageSize: integer, [fn(err, value)]])

Retrieves the first resource page. It optionally accepts as first argument the page size to return. Otherwise it will use maxResults property value. The second argument is a callback which will received returned resources.

next: fn([pageSize: integer, [fn(err, value)]])

Retrieves subsequent resource pages. Pushing the newly returned resources at the end of the array.

getTotalResults: fn()

Returns the total count of resources in the backend for the current resource. This is different to length property. length represents the count of already fetched resources while getTotalResults() represents the total count of resources available for retrieval.