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

@hydralerne/youtube-api

v1.1.5

Published

Fast and simple API for YouTube and YouTube Music

Readme

YouTube & YouTube Music API

A powerful, lightweight, and high-performance API for accessing YouTube and YouTube Music content, metadata, and streams. Designed for simplicity and flexibility, this library provides full access to YouTube sources, including videos, playlists, metadata, and more.


Performance Comparison

This library is optimized for speed, making it significantly faster than other solutions like ytdl-core. Here's a performance comparison:

  • Hydra YouTube API: ~300ms (approximate)
  • ytdl-core: 2-1.5 seconds (approximate)

Speed Improvement

On average, the Hydra YouTube API is:

  • ~6x faster than ytdl-core when processing video data.

This makes it an excellent choice for applications requiring low latency and quick responses.

Features

  • 🎥 Video Support: Fetch and download YouTube videos effortlessly.
  • 🎵 Music Support: Stream and download YouTube Music tracks seamlessly.
  • 📊 Metadata Extraction: Retrieve detailed metadata for videos, songs, playlists, and artists.
  • 🌍 Multilingual Support: Compatible with multiple languages.
  • High Performance: Optimized for speed and efficiency.
  • 🔄 Flexible Output: Get video or audio in your preferred format.

Installation

Install the package via npm:

npm install @hydralerne/youtube-api

API Reference

Core Functions

getVideoId(q: string, isYoutube: boolean): Promise<string | { error: string }>

Retrieves the YouTube video ID for a given song or title.

Parameters:

  • q: The search query (e.g., song name or title).
  • isYoutube: If true, searches YouTube; otherwise, searches YouTube Music.

Returns: The video ID or an error object.


getYoutubeList(id: string): Promise<PlaylistData | { error: string }>

Fetches metadata and tracks for a YouTube playlist.

Parameters:

  • id: The ID of the YouTube playlist.

Returns: Playlist metadata and track list.


getYotubeMusicList(id: string): Promise<PlaylistData | { error: string }>

Fetches metadata and tracks for a YouTube Music playlist.

Parameters:

  • id: The ID of the YouTube Music playlist.

Returns: Playlist metadata and track list.


youtubeMusicSearch(q: string, method: string = 'songs'): Promise<SearchResult[] | { error: string }>

Searches YouTube Music for songs, artists, albums, or playlists.

Parameters:

  • q: The search query.
  • method: The search category (songs, artists, albums, etc.).

Returns: An array of search results.


getRelatedAndLyrics(id: string): Promise<{ lyrics: string, list: any, related: any } | { error: string }>

Fetches related tracks, playlist queue, and lyrics for a given video ID.

Parameters:

  • id: The YouTube video ID.

Returns: Related tracks, playlist queue, and lyrics data.


getLyrics(id: string): Promise<string | { error: string }>

Fetches lyrics for a specific video ID.

Parameters:

  • id: The YouTube video ID.

Returns: Lyrics or an error object.


getYTMusicRelated(id: string): Promise<any | { error: string }>

Fetches related tracks for YouTube Music based on the provided ID.

Parameters:

  • id: The ID of the track.

Returns: Related track details.


getArtist(id: string): Promise<any | { error: string }>

Fetches information about an artist.

Parameters:

  • id: The artist ID.

Returns: Artist details.


getAlbum(id: string): Promise<any | { error: string }>

Fetches information about an album.

Parameters:

  • id: The album ID.

Returns: Album details.


getTrackData(id: string): Promise<TrackData | { error: string }>

Fetches detailed track data, including artist, album, duration, and poster information.

Parameters:

  • id: The track ID.

Returns: Track metadata and details.


getPodcast(id: string): Promise<any | { error: string }>

Fetches details about a podcast.

Parameters:

  • id: The podcast ID.

Returns: Podcast details.


Usage Examples

Fetching YouTube Video Data

import { getData, filter } from '@hydralerne/youtube-api';

const videoId = 'dQw4w9WgXcQ'; // Example video ID
const data = await getData(videoId);
const bestVideo = filter(data, 'bestvideo', { minResolution: 1080 });
console.log(bestVideo);

Searching YouTube Music

import { youtubeMusicSearch } from '@hydralerne/youtube-api';

const results = await youtubeMusicSearch('Imagine Dragons', 'songs');
console.log(results);

Fetching a YouTube Playlist

import { getYoutubeList } from '@hydralerne/youtube-api';

const playlistId = 'PLABC123456789'; // Example playlist ID
const playlist = await getYoutubeList(playlistId);
console.log(playlist);

Retrieving YouTube Music Home Page

import { getHome } from '@hydralerne/youtube-api';

const homeData = await getHome();
console.log(homeData);

Advanced Filtering

The filter function supports advanced filtering options:

const formats = await getData(videoId);
const bestAudio = filter(formats, 'bestaudio', { minBitrate: 128000, codec: 'mp4a' });
console.log(bestAudio);