π A powerful yet lightweight YouTube search wrapper for Node.js. Fetch videos, channels, playlists, movies, and live streams effortlessly without using the official API. Supports advanced playlist pagination with customizable user page limits, detailed video metadata fetching, sortable search results, combined multi-type search (via
any), and comprehensive error handling β all via a clean, developer-friendly API.
npm install ytsearch.jsRequires Node.js v14+ (ESM supported).
const { searchYouTube } = require("ytsearch.js");
(async () => {
const results = await searchYouTube("Black Panther", {
type: "video",
limit: 10,
});
results.videos.forEach((item) => console.log(item.type, item.title));
})();import { searchYouTube } from "ytsearch.js";
const results = await searchYouTube("Black Panther", {
type: "channel",
limit: 10,
});
results.channels.forEach((item) => console.log(item.type, item.title));Full API documentation, examples, and error handling are available on the GitHub Wiki.
searchYouTube(query: string, options?: SearchOptions): Promise<SearchResult>;interface SearchOptions {
type?: "video" | "channel" | "playlist" | "movie" | "live" | "any";
sort?: "relevance" | "upload_date" | "view_count" | "rating";
limit?: number; // 10β50 (default: 20)
}interface SearchResult {
videos: VideoResult[];
channels: ChannelResult[];
playlists: PlaylistResult[];
movies: VideoResult[];
lives: VideoResult[];
metadata: SearchMetadata;
nextPage: () => Promise<SearchResult | null>;
}- If
typeis specific (video,channel, etc.), only that array will be filled. - If
typeis any, results includevideos,channels, andplaylists. (moviesandlivesare grouped undervideos).
β Page size is limited to 10β50 to prevent excessive YouTube requests. Requests are buffered intelligently β YouTube is queried only when needed.
Fetch a playlist with videos and pagination support.
getPlaylistItems(playlistId: string, options?: PlaylistOptions): Promise<PlaylistDetailsResult>;interface PlaylistOptions {
limit?: number; // 10β100 (default: 50)
}interface PlaylistDetailsResult {
playlist: PlaylistInfo;
videos: PlaylistVideo[];
metadata: PlaylistMetadata;
nextPage: () => Promise<PlaylistDetailsResult | null>;
}Metadata includes YouTube page tracking, user page size, and total video count.
Fetch detailed metadata for a specific video by video ID.
getVideoDetails(videoID: string): Promise<VideoDetailsResult>;- Fork this repo
- Create a feature branch (
git checkout -b feature/awesome) - Commit changes (
git commit -m 'Add awesome feature') - Push branch (
git push origin feature/awesome) - Create a Pull Request π
MIT Β© 2025 RJRYT