A Node.js module that downloads YouTube videos and exposes a streaming API. It fetches video metadata and returns readable download streams.
Overview
node-ytdl-core is a JavaScript module for downloading videos from YouTube inside Node.js applications. It is built with only JavaScript and exposes a Node-friendly streaming interface so callers can pipe output to files or other streams.
The main entry point attempts to download from a URL and returns a readable stream. Supporting APIs retrieve basic or full video metadata, choose among available formats, validate IDs and URLs, and download using metadata already fetched. Options cover partial byte ranges, start offsets within the video, live stream buffering, chunk sizes for split audio or video downloads, and rotation through an IPv6 block as an alternative to proxies.
The library emits progress and info events as chunks arrive and forwards miniget request events from the returned stream. Callers can filter formats by quality, container, or custom rules, and can handle cases where high-resolution video and audio arrive as separate streams meant to be merged externally.
Operation depends on YouTube’s site remaining compatible with the module’s parsing logic. Downloads can fail for region-locked, private, rental, or Premium content without appropriate proxies or cookies. Heavy request volume can trigger HTTP 429 responses; mitigations mentioned in the source include proxies, cookies, IPv6 rotation, and staying on a current package build.
Key features
- Readable stream downloads from YouTube URLs
- Metadata queries with format lists
- Manual format selection and filtering
- Progress and info stream events
- Live video timing and buffer options
- Partial range and chunk download controls
- URL and video ID validation helpers
- Optional IPv6 block rotation for requests
Use cases
- Building bots that fetch YouTube media
- Piping video or audio into transcoders
- Inspecting available formats before download
- Streaming live YouTube feeds with offsets
- Integrating downloads into Node services