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

yt-search-lib

v1.3.0

Published

Premium client-side YouTube search library using InnerTube API patterns. No API key required.

Readme

YouTube Search Library

A powerful, purely client-side JavaScript library for searching YouTube videos without an official API key. It uses YouTube's internal InnerTube API pattern and provides a high-performance, cached searching experience.

✨ Features

  • No API Key Required: Works by emulating the internal YouTube web client.
  • 100% Client-Side: No server-side code needed (bypasses CORS via configurable proxies).
  • Persistent LRU Cache: Automatically stores results in localStorage to save bandwidth and improve speed.
  • Rich Metadata: Returns titles, high-res thumbnails, watch links, durations, view counts, and channel names.
  • Modular & Lightweight: Zero dependencies, built with modern ES Modules.
  • Premium Demo: Includes a state-of-the-art, glassmorphic search interface.

🚀 Quick Start

1. Installation

npm install yt-search-lib

2. Usage

import YouTubeClient from 'yt-search-lib';

// Initialize the client
const client = new YouTubeClient({
  // Bypassing CORS is mandatory for browser usage
  proxyUrl: 'https://api.allorigins.win/raw?url=', 
  useCache: true,
  cacheMaxAge: 3600000 // 1 hour in ms
});

// Perform a search
async function search() {
  try {
    const results = await client.search('lofi hip hop', { limit: 5 });
    
    results.forEach(video => {
      console.log(`Title: ${video.title}`);
      console.log(`Link: ${video.link}`);
      console.log(`Thumbnail: ${video.thumbnail_url}`);
    });
  } catch (err) {
    console.error('Search failed:', err);
  }
}

search();

📂 Project Structure

  • src/index.js: Main library entry point.
  • src/lib/parser.js: Robust logic for parsing YouTube's complex JSON responses.
  • src/lib/transport.js: Network layer with proxy and error handling.
  • src/lib/cache.js: LocalStorage-based LRU caching mechanism.
  • src/lib/constants.js: InnerTube configuration and API keys.
  • index.html: A premium, responsive demo page.

⚙️ Configuration

The YouTubeClient constructor accepts an options object:

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | proxyUrl | string | '' | Prefix URL for a CORS proxy. | | useCache | boolean | true | Enable or disable localStorage caching. | | cacheMaxAge| number | 3600000 | How long to keep results in cache (ms). | | clientContext| object | WEB | Override the InnerTube client version/name. |

⚠️ Important Note on CORS

Browsers block direct requests to YouTube. To use this library in a browser, you must use a CORS proxy.

  • For development: https://api.allorigins.win/raw?url= or https://cors-anywhere.herokuapp.com/
  • For production: It is highly recommended to host your own simple proxy server for stability and security.

📜 License

MIT