Gathering detailed insights and metrics for @distube/ytdl-core
Gathering detailed insights and metrics for @distube/ytdl-core
Gathering detailed insights and metrics for @distube/ytdl-core
Gathering detailed insights and metrics for @distube/ytdl-core
@distube/ytdl
A discord-ytdl-core fork. Made for DisTube.js.org
garfield-ytdl
DisTube fork of ytdl-core. YouTube video downloader in pure javascript.
@quanghd96/ytdl-core
DisTube fork of ytdl-core. YouTube video downloader in pure javascript.
@rablonkk/ytdl-core
DisTube fork of ytdl-core. YouTube video downloader in pure javascript.
npm install @distube/ytdl-core
Typescript
Module System
Min. Node Version
Node Version
NPM Version
96.3
Supply Chain
98.4
Quality
92.4
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
3,769,547
Last Day
84,289
Last Week
482,495
Last Month
874,484
Last Year
2,527,147
MIT License
463 Stars
1,176 Commits
76 Forks
19 Watchers
4 Branches
Updated on Apr 24, 2025
Latest Version
4.16.8
Package Id
@distube/ytdl-core@4.16.8
Unpacked Size
125.20 kB
Size
32.57 kB
File Count
14
NPM Version
10.8.2
Node Version
20.19.0
Published on
Apr 05, 2025
Cumulative downloads
Total Downloads
Last Day
24.4%
84,289
Compared to previous day
Last Week
90.8%
482,495
Compared to previous week
Last Month
218.5%
874,484
Compared to previous month
Last Year
626.3%
2,527,147
Compared to previous year
3
[!WARNING] @distube/youtube depends on youtubei.js from now on. This fork will be no longer maintained. Please use alternatives instead.
DisTube fork of ytdl-core
. This fork is dedicated to fixing bugs and adding features that are not merged into the original repo as soon as possible.
1npm install @distube/ytdl-core@latest
Make sure you're installing the latest version of @distube/ytdl-core
to keep up with the latest fixes.
1const ytdl = require("@distube/ytdl-core"); 2// TypeScript: import ytdl from '@distube/ytdl-core'; with --esModuleInterop 3// TypeScript: import * as ytdl from '@distube/ytdl-core'; with --allowSyntheticDefaultImports 4// TypeScript: import ytdl = require('@distube/ytdl-core'); with neither of the above 5 6// Download a video 7ytdl("http://www.youtube.com/watch?v=aqz-KE-bpKQ").pipe(require("fs").createWriteStream("video.mp4")); 8 9// Get video info 10ytdl.getBasicInfo("http://www.youtube.com/watch?v=aqz-KE-bpKQ").then(info => { 11 console.log(info.videoDetails.title); 12}); 13 14// Get video info with download formats 15ytdl.getInfo("http://www.youtube.com/watch?v=aqz-KE-bpKQ").then(info => { 16 console.log(info.formats); 17});
1const ytdl = require("@distube/ytdl-core"); 2 3// (Optional) Below are examples, NOT the recommended options 4const cookies = [ 5 { name: "cookie1", value: "COOKIE1_HERE" }, 6 { name: "cookie2", value: "COOKIE2_HERE" }, 7]; 8 9// (Optional) http-cookie-agent / undici agent options 10// Below are examples, NOT the recommended options 11const agentOptions = { 12 pipelining: 5, 13 maxRedirections: 0, 14 localAddress: "127.0.0.1", 15}; 16 17// agent should be created once if you don't want to change your cookie 18const agent = ytdl.createAgent(cookies, agentOptions); 19 20ytdl.getBasicInfo("http://www.youtube.com/watch?v=aqz-KE-bpKQ", { agent }); 21ytdl.getInfo("http://www.youtube.com/watch?v=aqz-KE-bpKQ", { agent });
[!WARNING] Don't logout it by clicking logout button on youtube/google account manager, it will expire your cookies. You can delete your browser's cookies to log it out on your browser. Or use incognito mode to get your cookies then close it.
[!WARNING] Paste all the cookies array from clipboard into
createAgent
function. Don't remove/edit any cookies if you don't know what you're doing.
[!WARNING] Make sure your account, which logged in when you getting your cookies, use 1 IP at the same time only. It will make your cookies alive longer.
1const ytdl = require("@distube/ytdl-core"); 2const agent = ytdl.createAgent([ 3 { 4 domain: ".youtube.com", 5 expirationDate: 1234567890, 6 hostOnly: false, 7 httpOnly: true, 8 name: "---xxx---", 9 path: "/", 10 sameSite: "no_restriction", 11 secure: true, 12 session: false, 13 value: "---xxx---", 14 }, 15 { 16 "...": "...", 17 }, 18]);
fs.readFileSync
to read it.1const ytdl = require("@distube/ytdl-core"); 2const fs = require("fs"); 3const agent = ytdl.createAgent(JSON.parse(fs.readFileSync("cookies.json")));
1const ytdl = require("@distube/ytdl-core"); 2 3const agent = ytdl.createProxyAgent({ uri: "my.proxy.server" }); 4 5ytdl.getBasicInfo("http://www.youtube.com/watch?v=aqz-KE-bpKQ", { agent }); 6ytdl.getInfo("http://www.youtube.com/watch?v=aqz-KE-bpKQ", { agent });
Use both proxy and cookies:
1const ytdl = require("@distube/ytdl-core"); 2 3const agent = ytdl.createProxyAgent({ uri: "my.proxy.server" }, [{ name: "cookie", value: "COOKIE_HERE" }]); 4 5ytdl.getBasicInfo("http://www.youtube.com/watch?v=aqz-KE-bpKQ", { agent }); 6ytdl.getInfo("http://www.youtube.com/watch?v=aqz-KE-bpKQ", { agent });
Built-in ip rotation (getRandomIPv6
) won't be updated and will be removed in the future, create your own ip rotation instead.
To implement IP rotation, you need to assign the desired IP address to the localAddress
property within undici.Agent.Options
.
Therefore, you'll need to use a different ytdl.Agent
for each IP address you want to use.
1const ytdl = require("@distube/ytdl-core");
2const { getRandomIPv6 } = require("@distube/ytdl-core/lib/utils");
3
4const agentForARandomIP = ytdl.createAgent(undefined, {
5 localAddress: getRandomIPv6("2001:2::/48"),
6});
7
8ytdl.getBasicInfo("http://www.youtube.com/watch?v=aqz-KE-bpKQ", { agent: agentForARandomIP });
9
10const agentForAnotherRandomIP = ytdl.createAgent(undefined, {
11 localAddress: getRandomIPv6("2001:2::/48"),
12});
13
14ytdl.getInfo("http://www.youtube.com/watch?v=aqz-KE-bpKQ", { agent: agentForAnotherRandomIP });
You can find the API documentation in the original repo. Except a few changes:
ytdl.getInfoOptions
requestOptions
is now undici
's RequestOptions
.agent
: ytdl.Agent
playerClients
: An array of player clients to use. Accepts WEB
, WEB_EMBEDDED
, TV
, IOS
, and ANDROID
. Defaults to ["WEB_EMBEDDED", "IOS", "ANDROID","TV"]
.fetch
: Custom fetch implementation. Defaults to undici
's request.ytdl.createAgent([cookies]): ytdl.Agent
cookies
: an array of json cookies exported with EditThisCookie.
ytdl.createProxyAgent(proxy[, cookies]): ytdl.Agent
proxy
: ProxyAgentOptions
contains your proxy server information.
ytdl.Agent
with your own DispatcherYou can find the example here
ytdl cannot download videos that fall into the following
Generated download links are valid for 6 hours, and may only be downloadable from the same IP address.
When doing too many requests YouTube might block. This will result in your requests getting denied with HTTP-StatusCode 429. The following steps might help you:
@distube/ytdl-core
to the latest versionThe issue of using an outdated version of ytdl-core became so prevalent, that ytdl-core now checks for updates at run time, and every 12 hours. If it finds an update, it will print a warning to the console advising you to update. Due to the nature of this library, it is important to always use the latest version as YouTube continues to update.
If you'd like to disable this update check, you can do so by providing the YTDL_NO_UPDATE
env variable.
env YTDL_NO_UPDATE=1 node myapp.js
No vulnerabilities found.
No security vulnerabilities found.