API Documentation - ybd-project/ytdl-core GitHub Wiki
YTDL-Core API Documentation
This document describes how to use ytdl-core and how to best use it.
Installation
To use it, you need to install @ybd-project/ytdl-core
from any location. The following uses npm, but you can use yarn or whatever.
npm install @ybd-project/ytdl-core@latest
Once installed, import using require
for JavaScript (Node.js) or import
for TypeScript.
/* For JS */
const { YtdlCore } = require('@ybd-project/ytdl-core');
/* For TS */
import { YtdlCore } from '@ybd-project/ytdl-core';
Basic usage
[!WARNING] All of the following code follows the above introduction and assumes that the
YtdlCore
class has been imported.
Create a YtdlCore instance
The most basic use of @ybd-project/ytdl-core
is to create class instances. Here is an example.
[!TIP] The instance can also be specified with options that will be the default options for functions to be executed thereafter. If the option is specified again for the function to be executed, it will take precedence.
/* Most basic use */
const ytdl = new YtdlCore();
ytdl.getBasicInfo('https://www.youtube.com/watch?v=ID');
/* ↑ This `getBasicInfo` function is executed without options. */
/* You can specify default options */
const ytdl = new YtdlCore({
lang: 'en',
...
});
ytdl.getBasicInfo('https://www.youtube.com/watch?v=ID');
/* ↑ This `getBasicInfo` function is executed with the option `lang: 'en'`. */
ytdl.getBasicInfo('https://www.youtube.com/watch?v=ID', {
lang: 'ja',
...
});
/* ↑ This `getBasicInfo` function is executed with the option `lang` overridden from `en` to `ja`. */