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 🙏

© 2024 – Pkg Stats / Ryan Hefner

yt-list

v0.1.1

Published

JavaScript Wrapper for YouTube API on list methods

Downloads

25

Readme

yt-list npm downloads

JavaScript Wrapper for YouTube API on list methods

Simplify your life using this api to search videos, related videos, channel details, comments threads on YouTube. Results are on Youtube API response format

Install

npm install yt-list@latest

Usage

API expects a YOUTUBE_API_KEY variable with the API key Create .env file in the root of your project with your YouTube API Key

YOUTUBE_API_KEY=your youtube api key
const ytlist = require('yt-list')

API

Search

searchVideos(searchQuery, nextPageToken, amount)

Search videos based on a search query.

NextPageToken to retrieve the next page of results Amount of results per page

const searchResults = await ytlist.searchVideos(searchQuery, nextPageToken, amount);

// Response object
{
   totalResults: Integer,
   query: String,
   items: Array[Object], // YouTube API response format below
   nextPageToken: String,
}

// YouTube API response format
{
  "kind": "youtube#searchResult",
  "etag": etag,
  "id": {
    "kind": string,
    "videoId": string,
    "channelId": string,
    "playlistId": string
  },
  "snippet": {
    "publishedAt": datetime,
    "channelId": string,
    "title": string,
    "description": string,
    "thumbnails": {
      (key): {
        "url": string,
        "width": unsigned integer,
        "height": unsigned integer
      }
    },
    "videoId": string
  }
}

searchRelatedVideos(videoId, nextPageToken, amount)

Search Related Videos based on a videoId

NextPageToken to retrieve the next page of results Amount of results per page

const searchRelatedResults = await ytlist.searchRelatedVideos(videoId, nextPageToken, amount);

// Response object
{
   totalResults: Integer,
   items: Array[String], // Related Video Ids
   nextPageToken: String,
}

Channels

listChannelDetails(channelId)

List channel details by ChannelId

const channel = await ytlist.listChannelDetails(channelId);

// Response object
{
  channelId: String,
  snippet: {
    title: String,
    description: String,
    thumbnails: { medium: [Object] }
  },
  statistics: { subscriberCount: String }
}

Comments

listCommentThreads (videoId, nextPageToken)

List comment threads of a videoId

NextPageToken to retrieve the next page of results

const comments = await ytlist.listCommentThreads(videoId, nextPageToken);

// Response object
{
   pageInfo: { totalResults: Integer, resultsPerPage: Integer },
   items: Array[Object], // YouTube API response format below
   videoId: String,
   nextPageToken: String,
}

// YouTube API response format
{
  "kind": "youtube#commentThread",
  "etag": etag,
  "id": string,
  "snippet": {
    "channelId": string,
    "videoId": string,
    "topLevelComment": comments Resource,
    "canReply": boolean,
    "totalReplyCount": unsigned integer,
    "isPublic": boolean
  },
  "replies": {
    "comments": [
      comments Resource
    ]
  }
}

{
  "kind": "youtube#comment",
  "etag": etag,
  "id": string,
  "snippet": {
    "authorDisplayName": string,
    "authorProfileImageUrl": string,
    "authorChannelUrl": string,
    "authorChannelId": {
      "value": string
    },
    "channelId": string,
    "videoId": string,
    "textDisplay": string,
    "textOriginal": string,
    "parentId": string,
    "canRate": boolean,
    "viewerRating": string,
    "likeCount": unsigned integer,
    "moderationStatus": string,
    "publishedAt": datetime,
    "updatedAt": datetime
  }
}

Videos

listVideoDetails(videoId)

List video details by VideoId

const video = await ytlist.listVideoDetails(viodeId);

// Response object
{
  "videoId": String,
  "snippet": {
    "publishedAt": datetime,
    "channelId": string,
    "title": string,
    "description": string,
    "thumbnails": {
      (key): {
        "url": string,
        "width": unsigned integer,
        "height": unsigned integer
      }
    },
    "channelTitle": string,
    "tags": [
      string
    ],
    "categoryId": string,
    "liveBroadcastContent": string,
    "defaultLanguage": string,
    "localized": {
      "title": string,
      "description": string
    },
    "defaultAudioLanguage": string
  },
  "contentDetails": {
    "duration": string,
    "dimension": string,
    "definition": string,
    "caption": string,
    "licensedContent": boolean,
    "regionRestriction": {
      "allowed": [
        string
      ],
      "blocked": [
        string
      ]
  },
  "statistics": {
    "viewCount": unsigned long,
    "likeCount": unsigned long,
    "dislikeCount": unsigned long,
    "favoriteCount": unsigned long,
    "commentCount": unsigned long
  }
}

Tests

Tests are written with mocha

npm test