An ultra-fast, zero-dependency, lightweight JavaScript library and All-in-One Music Engine built to extract direct audio/video stream URLs, perform high-quality YouTube search queries, and drive Unlimited Anti-Duplicate Autoplay Loops.
Works out-of-the-box in Node.js (18+), Browsers, Discord Bots (discord.js/voice), and modern Edge environments without any Supabase or Google API Key requirement!
📖 Documentation: Read the complete API Guide for full details on response parameters.
- ⚡ Zero External Backend/API Keys Needed: Operates without Google API key rate limits or Supabase configuration.
- 🔊 Direct Playable Audio Streams: High bitrate streams (Opus/M4A up to 320kbps) ready for direct HTML5 audio
<audio src="...">or Discord Audio Resource. - 🎯 Smart HQ Search (
searchYouTube): Automatically prioritizes Official Audio, Topic channels, and Studio Mastered releases. - ♾️ Unlimited Autoplay Engine (
getAutoplay): Powered by Harmonix Bot algorithms:- Zero Duplicate Repeats: Strict title & semantic deduplication.
- Bad Variation Filter: Excludes unwanted lofi/slowed/reverb/remixes automatically.
- Multi-Strategy Infinite Queue: Artist hits -> Genre hits -> Similar tracks loop.
- 📦 Dual Module Bundle: Full ES Modules (
import) and CommonJS (require) support.
npm install yt-music-engineimport { searchYouTube } from 'youtube-stream-extractor';
const results = await searchYouTube('Kesariya', { limit: 5 });
console.log(results[0]);
/*
{
videoId: 'W1S9AbHpWFY',
title: 'Kesariya (Lyrics) Full Song - Brahmastra | Arijit Singh',
channelName: '7clouds',
thumbnail: 'https://img.youtube.com/vi/W1S9AbHpWFY/hqdefault.jpg',
duration: '266',
youtubeUrl: 'https://www.youtube.com/watch?v=W1S9AbHpWFY',
audioUrl: 'https://pipedapi.kavin.rocks/streams/W1S9AbHpWFY'
}
*/import { getStreamUrls } from 'youtube-stream-extractor';
const streams = await getStreamUrls('W1S9AbHpWFY');
// Play directly in browser:
// const audio = new Audio(streams.audioUrl);
// audio.play();
console.log('Audio Stream Link:', streams.audioUrl);import { searchYouTube, getAutoplay } from 'youtube-stream-extractor';
// 1. Initial Track
const search = await searchYouTube('Sahiba');
let currentTrack = search[0];
const history = [currentTrack.title];
console.log('Playing:', currentTrack.title);
// 2. Fetch Next Recommendations for Infinite Loop
const nextTracks = await getAutoplay({
title: currentTrack.title,
author: currentTrack.channelName,
videoId: currentTrack.videoId
}, {
existingTitles: history, // Pass history to prevent duplicate repeats
limit: 10
});
console.log('Next Autoplay Song:', nextTracks[0].title);query(string, required): Keyword to search.options(object, optional):{ limit: 10 }(Default limit: 10, Max: 25).
Returns: Promise<Array<TrackItem>>
videoId(string, required): YouTube Video ID or full video link.
Returns: Promise<{ videoId, title, thumbnail, audioUrl, videoUrl, duration, artist }>
baseTrack(object, required):{ title, author, videoId }options(object, optional):existingTitles(Array): List of previously played song titles to exclude duplicate repeats.limit(number): Number of autoplay songs to return (Default: 10).
Returns: Promise<Array<TrackItem>>
Distributed under the MIT License. Maintained by iy3k / Sagexdd.