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

@forkprince/youtube-search-api

v1.0.3

Published

A lightweight package for retrieving data from YouTube without needing an API key.

Downloads

27

Readme

YouTube Search API

A lightweight package for retrieving data from YouTube without needing an API key.

Features

  • Fetch search results for videos, playlists, or channels by keyword.
  • Retrieve paginated results for extended searches.
  • Access playlist details and video information.
  • Fetch channel data by channel ID.

Installation

Install the package via npm:

npm install @forkprince/youtube-search-api

Usage

1. Search for Videos, Playlists, or Channels

Fetch a list of items based on a keyword. You can specify whether to include playlists and set a limit on the number of results.

youtube.getListByKeyword(keyword: string, playlist?: boolean, limit?: number, options?: [{ type: "string" }]);

Example:

const search = await youtube.getListByKeyword("JavaScript tutorials", true, 5, [{ type: "video" }]);
console.log(search);

2. Fetch Next Page of Results

Continue retrieving results using pagination.

youtube.nextPage({ token, context, continuation }, playlist?: boolean, limit?: number);

Example:

const nextPage = await youtube.nextPage(results.next, true, 5);
console.log(nextPage);

3. Get Playlist Data

Retrieve detailed information about a playlist, including videos in the playlist.

youtube.getPlaylistData(id: string, limit?: number);

Example:

const playlist = await youtube.getPlaylistData("RDCLAK5uy_lGZNsVQescoTzcvJkcEhSjpyn_98D4lq0");
console.log(playlist);

4. Get Channel Information

Fetch details about a channel using its channel ID.

youtube.getChannelById(id: string);

Example:

const channel = await youtube.getChannelById("UCj-Xm8j6WBgKY8OG7s9r2vQ");
console.log(channel);

5. Get Video Details

Retrieve information about a specific video.

youtube.getVideoDetails(id: string);

Example:

const video = await youtube.getVideoDetails("cC2UqBuFAEY");
console.log(video);

Example

Here’s a complete example demonstrating how to use the package:

const youtube = require("@forkprince/youtube-search-api");

async function test() {
  // Search for videos
  const videos = await youtube.getListByKeyword("JSDeveloper", true, 2, [{ type: "video" }]);
  console.log("Videos:", videos);

  // Get the next page of results
  const page2 = await youtube.nextPage(videos.next, true, 2);
  console.log("Page 2:", page2);

  const page3 = await youtube.nextPage(page2.next, true, 2);
  console.log("Page 3:", page3);

  // Get playlist data
  const playlist = await youtube.getPlaylistData("RDCLAK5uy_lGZNsVQescoTzcvJkcEhSjpyn_98D4lq0");
  console.log("Playlist:", playlist);

  // Get channel data
  const channel = await youtube.getChannelById("UCj-Xm8j6WBgKY8OG7s9r2vQ");
  console.log("Channel:", channel);

  // Get video details
  const video = await youtube.getVideoDetails("cC2UqBuFAEY");
  console.log("Video Details:", video);
}

test();

License

This package is licensed under the MIT License.