No description
  • TypeScript 100%
Find a file
2025-09-22 14:34:36 +02:00
.github bump node version 2024-10-26 11:49:17 +07:00
.vscode update settings 2024-01-08 21:36:52 +07:00
@types add search params 2022-07-11 21:41:38 +07:00
docs add proxy snippet 2024-11-08 10:56:13 +08:00
src fix: https://github.com/SuspiciousLookingOwl/youtubei/issues/148 2025-09-22 14:34:36 +02:00
tests Add test case for Channel.posts 2025-07-25 02:27:19 +09:00
typescript build using tsc 2022-07-11 19:58:11 +07:00
.eslintignore add website folder 2021-02-23 21:28:41 +07:00
.eslintrc.js allow namespace 2022-07-11 19:58:30 +07:00
.gitignore add .vscode 2022-07-10 09:35:47 +07:00
.npmignore update npmignore 2021-02-22 03:14:14 +07:00
.prettierignore add import order plugins 2022-07-11 19:58:21 +07:00
.prettierrc.js add import order plugins 2022-07-11 19:58:21 +07:00
CHANGELOG.md initial commit 2021-02-14 12:47:34 +07:00
LICENSE initial commit 2021-02-14 12:47:34 +07:00
package.json 1.7.0 2025-07-10 20:02:23 +08:00
pnpm-lock.yaml update lock 2024-10-26 11:44:50 +07:00
README.md add music doc 2023-01-07 16:35:28 +07:00
tsconfig.json add dev script 2022-07-11 21:54:58 +07:00
vite.config.ts increase test timeout 2022-07-13 14:38:07 +07:00

Youtubei

Youtubei is made to replace my other library scrape-yt. Instead of scrapping data from Youtube page, youtubei fetches data by sending a request directly to https://www.youtube.com/youtubei/v1, which should be faster and provide more reliable result.

Requires Node >= 16

Documentation

Installation

npm i youtubei

or use the dev build directly from GitHub:

npm i git://github.com/suspiciouslookingowl/youtubei.git#dist

Example

const { Client, MusicClient } = require("youtubei");
// or for TS / ES6
import { Client, MusicClient } from "youtubei";

const youtube = new Client();
const music = new MusicClient();

const run = async () => {
	const videos = await youtube.search("Never gonna give you up", {
		type: "video", // video | playlist | channel | all
	});

	console.log(videos.items.length); // 20
	const nextVideos = await videos.next(); // load next page
	console.log(nextVideos.length); // 18-20, inconsistent next videos count from youtube
	console.log(videos.items.length); // 38 - 40

	// you can also pass the video URL
	const video = await youtube.getVideo("dQw4w9WgXcQ");

	const channelVideos = await video.channel.videos.next();
	const channelPlaylists = await video.channel.playlists.next();

	// you can also pass the playlist URL
	const playlist = await youtube.getPlaylist("UUHnyfMqiRRG1u-2MsSQLbXA");
	console.log(playlist.videos.items.length); // first 100 videos;
	let newVideos = await playlist.videos.next(); // load next 100 videos
	console.log(playlist.videos.items.length); // 200 videos;
	await playlist.videos.next(0); // load the rest videos in the playlist

	// search using music client
	const shelves = await music.search("Never gonna give you up");
	console.log(shelves);
};

run();