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

newpipe-extractor-js

v1.0.33

Published

JavaScript/Node.js port of NewPipeExtractor

Readme

NewPipe Extractor JS

npm version npm downloads License: GPL v3

A comprehensive JavaScript/TypeScript port of the NewPipeExtractor library for extracting data from YouTube and other video streaming services.

🚀 NEW: Now includes comprehensive YouTube search functionality without requiring API keys!

Features

  • 🎵 Audio Stream Extraction - Extract high-quality audio streams from YouTube videos
  • 🎬 Video Stream Extraction - Extract video streams in various qualities and formats
  • 🔍 YouTube Search - Search YouTube content without API keys (videos, channels, playlists)
  • 💡 Search Suggestions - Get search autocomplete suggestions
  • 🔓 Signature Decryption - Automatic handling of YouTube's signature/cipher decryption
  • 🍪 Cookie Support - Support for authentication cookies (JSON format)
  • 🌍 Localization - Multi-language and region support
  • 📱 Multiple Services - Extensible architecture (currently supports YouTube)
  • 🚀 High Performance - Efficient caching and parallel processing
  • 📦 TypeScript Support - Full TypeScript definitions included
  • 🔧 No API Keys Required - Uses Android client simulation like NewPipe app

Installation

npm install newpipe-extractor-js

Quick Start

Basic Stream Extraction

import { initializeNewPipe, extractStreamInfo, getBestAudioStream } from 'newpipe-extractor-js';

// Initialize the extractor
initializeNewPipe();

// Extract stream information
const streamInfo = await extractStreamInfo('https://www.youtube.com/watch?v=dQw4w9WgXcQ');

console.log('Title:', streamInfo.name);
console.log('Uploader:', streamInfo.uploaderName);
console.log('Duration:', streamInfo.length);

// Get the best quality audio stream
const bestAudio = getBestAudioStream(streamInfo);
if (bestAudio) {
  console.log('Best audio URL:', bestAudio.url);
  console.log('Format:', bestAudio.format);
  console.log('Bitrate:', bestAudio.bitrate);
}

YouTube Search (No API Key Required!)

import { searchYoutube, getYoutubeSearchSuggestions } from 'newpipe-extractor-js';

// Initialize first
initializeNewPipe();

// Search for videos
const searchResults = await searchYoutube('JavaScript tutorial', ['videos']);
console.log(`Found ${searchResults.items.length} videos:`);

searchResults.items.forEach((item, index) => {
  console.log(`${index + 1}. ${item.name} by ${item.uploaderName}`);
  console.log(`   Views: ${item.viewCount} | Duration: ${item.duration}s`);
  console.log(`   URL: ${item.url}`);
});

// Get search suggestions
const suggestions = await getYoutubeSearchSuggestions('javascript');
console.log('Suggestions:', suggestions);

Advanced Usage

Using Cookies for Authentication

import { initializeNewPipe, DefaultDownloader } from 'newpipe-extractor-js';
import * as fs from 'fs';

// Load cookies from JSON file
const cookieJson = JSON.parse(fs.readFileSync('cookies.json', 'utf-8'));

// Initialize with cookies
initializeNewPipe(cookieJson);

// Now you can access age-restricted or premium content
const streamInfo = await extractStreamInfo('https://www.youtube.com/watch?v=VIDEO_ID');

Custom Downloader Configuration

import { NewPipe, DefaultDownloader, YoutubeService } from 'newpipe-extractor-js';

// Create custom downloader with user agent
const downloader = new DefaultDownloader(
  undefined, // CookieJar (optional)
  'Custom-User-Agent/1.0' // Custom user agent
);

// Initialize NewPipe
NewPipe.init(downloader);
NewPipe.registerService(new YoutubeService());

// Load cookies manually
await downloader.loadCookiesFromJson(cookieArray);

Setting Localization

import { setPreferredLocalization, setPreferredContentCountry } from 'newpipe-extractor-js';

// Set language preference
setPreferredLocalization({ languageCode: 'en', countryCode: 'US' });

// Set content country (affects trending, etc.)
setPreferredContentCountry({ languageCode: 'en', countryCode: 'GB' });

API Reference

Core Functions

initializeNewPipe(cookieJson?, userAgent?)

Initialize the NewPipe extractor with optional cookies and user agent.

extractStreamInfo(url: string): Promise<StreamInfo>

Extract complete stream information from a video URL.

isUrlSupported(url: string): boolean

Check if a URL is supported by any registered service.

getBestAudioStream(streamInfo: StreamInfo)

Get the highest quality audio stream from extracted stream info.

getBestVideoStream(streamInfo: StreamInfo)

Get the highest quality video stream from extracted stream info.

Types

interface StreamInfo {
  id: string;
  name: string;
  url: string;
  uploaderName?: string;
  uploaderUrl?: string;
  thumbnails: Image[];
  description?: string;
  length: number;
  viewCount: number;
  uploadDate?: string;
  audioStreams: AudioStream[];
  videoStreams: VideoStream[];
  videoOnlyStreams: VideoStream[];
  dashMpdUrl?: string;
  hlsUrl?: string;
  // ... and more
}

interface AudioStream {
  url?: string;
  itag?: number;
  bitrate?: number;
  format: MediaFormat;
  quality?: string;
  codec?: string;
  // ... and more
}

interface VideoStream {
  url?: string;
  itag?: number;
  bitrate?: number;
  format: MediaFormat;
  resolution?: string;
  fps?: number;
  width?: number;
  height?: number;
  isVideoOnly?: boolean;
  // ... and more
}

Supported Services

  • ✅ YouTube - Full support including signature decryption
  • 🚧 SoundCloud - Planned
  • 🚧 PeerTube - Planned
  • 🚧 Bandcamp - Planned
  • 🚧 Media.ccc.de - Planned

Examples

Extract All Available Streams

const streamInfo = await extractStreamInfo(videoUrl);

console.log('Audio Streams:');
streamInfo.audioStreams.forEach((stream, index) => {
  console.log(`${index + 1}. ${stream.format} - ${stream.bitrate}bps - ${stream.quality}`);
});

console.log('Video Streams:');
streamInfo.videoStreams.forEach((stream, index) => {
  console.log(`${index + 1}. ${stream.format} - ${stream.resolution} - ${stream.bitrate}bps`);
});

Handle Different URL Formats

const urls = [
  'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
  'https://youtu.be/dQw4w9WgXcQ',
  'dQw4w9WgXcQ' // Just the video ID
];

for (const url of urls) {
  if (isUrlSupported(url)) {
    const streamInfo = await extractStreamInfo(url);
    console.log(`Successfully extracted: ${streamInfo.name}`);
  }
}

Error Handling

try {
  const streamInfo = await extractStreamInfo(url);
  // Process stream info
} catch (error) {
  if (error instanceof ContentNotAvailableException) {
    console.log('Video is not available (private, deleted, or geo-blocked)');
  } else if (error instanceof AgeRestrictedException) {
    console.log('Video is age-restricted - cookies may be required');
  } else if (error instanceof ParsingException) {
    console.log('Failed to parse video data');
  } else {
    console.log('Unknown error:', error.message);
  }
}

Cookie Format

The library supports YouTube cookies in JSON format:

[
  {
    "name": "cookie_name",
    "value": "cookie_value",
    "domain": ".youtube.com",
    "path": "/",
    "secure": true,
    "httpOnly": false,
    "expirationDate": 1735689600
  }
]

You can export cookies from your browser using extensions like "Cookie Editor" or programmatically.

Development

# Clone the repository
git clone https://github.com/location/newpipe-extractor-js.git
cd newpipe-extractor-js

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test

# Run example
npm run dev examples/basic-usage.ts

Contributing

Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.

Acknowledgments

  • NewPipe Team for the original NewPipeExtractor
  • yt-dlp for YouTube extraction insights
  • All contributors and the open-source community

Disclaimer

This library is for educational and research purposes only. Please respect the terms of service of the platforms you're extracting data from.