YouTube Channel Info NodeJS Documentation
This library is designed to receive channel data from YouTube without accessing the official API.
This method has several advantages:
- No API key is required, which you should put next to your code;
- No restrictions on key usage (1 million quota)
But there are also disadvantages:
- Data acquisition time increases by many times;
- Any change to the YouTube DOM entails non-working methods of this library.
You must consider this before you use YouTube Channel Info
Installation
npm i yt-channel-info --save
Usage
// If using require
const ytch = require('yt-channel-info')
// If using import
import ytch from 'yt-channel-info'
API
getChannelInfo(channelId)
Returns information about a given channel ID.
const channelId = 'UCXuqSBlHAE6Xw-yeJA0Tunw'
ytch.getChannelInfo(channelId).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
})
// Response object
{
author: String,
authorId: String,
authorUrl: String,
authorBanners: Array[Object], // Will return null if none exist
authorThumbnails: Array[Object], // Will return null if none exist
subscriberText: String,
subscriberCount: Integer,
description: String,
isFamilyFriendly: Boolean,
relatedChannels: Array[Object],
allowedRegions: Array[String],
isVerified: Boolean,
}
getChannelVideos(channelId, [sortBy])
Grabs videos from a given channel ID.
newest
- Grabs videos from a channel sorted by newest / most recently uploaded (Default option if none given)oldest
- Grabs videos from a channel sorted by oldest videospopular
- Grabs videos from a channel sorted by the most popular (Highest amount of views)
const channelId = 'UCXuqSBlHAE6Xw-yeJA0Tunw'
const sortBy = 'newest'
ytch.getChannelVideos(channelId, sortBy).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
})
// Response object
{
items: Array[Object],
continuation: String // Will return null if no more results can be found. Used with getChannelVideosMore()
}
getChannelVideosMore(continuation)
Grabs more videos within a channel. Uses the continuation string returned from getChannelVideos()
or from past calls to getChannelVideosMore()
.
const continuation = '4qmFsgK9ARIYVUNYdXFTQmxIQUU2WHcteWVKQTBUdW53GqABRWdsd2JHRjViR2x6ZEhNZ0FYcG1VVlZzVUdFeGF6VlNiVkoyV1ZjNWJHVnNUbGhTUmxwWVZrVm9kR1ZHYTNoVU1EVnJUVWR3ZFdNd05VVmFSVVo0Vm10NGRsVnJWa2haYkd4dVUyNXZlbEpxUW5WT1YxRjNXbGhyTkZKcVVqVmhibEpXVkVVNWNtSkdUbnBaYXpWWVUxZDNNMVpSdUFFQQ%3D%3D'
ytch.getChannelInfoMore(continuation).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
})
// Response object
{
items: Array[Object],
continuation: String // Will return null if no more results can be found. Used with getChannelVideosMore()
}
getChannelPlaylistInfo(channelId, [sortBy])
Grabs playlist information of a given channel ID.
last
- Grabs playlists from a channel sorted by the most recently updated playlist (Default option if none given)newest
- Grabs playlists from a channel sorted by the creation date (newest first)
const channelId = 'UCXuqSBlHAE6Xw-yeJA0Tunw'
const sortBy = 'last'
ytch.getChannelPlaylistInfo(channelId, sortBy).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
})
// Response object
{
items: Array[Object],
continuation: String // Will return null if no more results can be found. Used with getChannelPlaylistsMore()
}
getChannelPlaylistsMore(continuation)
Grabs more playlists within a channel. Uses the continuation string returned from getChannelPlaylists()
or from past calls to getChannelPlaylistsMore()
.
const continuation = '4qmFsgK9ARIYVUNYdXFTQmxIQUU2WHcteWVKQTBUdW53GqABRWdsd2JHRjViR2x6ZEhNZ0FYcG1VVlZzVUdFeGF6VlNiVkoyV1ZjNWJHVnNUbGhTUmxwWVZrVm9kR1ZHYTNoVU1EVnJUVWR3ZFdNd05VVmFSVVo0Vm10NGRsVnJWa2haYkd4dVUyNXZlbEpxUW5WT1YxRjNXbGhyTkZKcVVqVmhibEpXVkVVNWNtSkdUbnBaYXpWWVUxZDNNMVpSdUFFQQ%3D%3D'
ytch.getChannelPlaylistsMore(continuation).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
})
// Response object
{
items: Array[Object],
continuation: String // Will return null if no more results can be found. Used with getChannelPlaylistsMore()
}
searchChannel(channelId, query)
Searchs for videos and playlists of a given channelId based on the given query
const channelId = 'UCXuqSBlHAE6Xw-yeJA0Tunw'
const query = 'linux'
ytch.searchChannel(channelId, query).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
})
// Response object
{
items: Array[Object],
continuation: String // Will return null if no more results can be found. Used with searchChannelMore()
}
searchChannelMore(continuation)
Grabs more search results within a channel. Uses the continuation string returned from searchChannel()
or from past calls to searchChannelMore()
.
const continuation = '4qmFsgK9ARIYVUNYdXFTQmxIQUU2WHcteWVKQTBUdW53GqABRWdsd2JHRjViR2x6ZEhNZ0FYcG1VVlZzVUdFeGF6VlNiVkoyV1ZjNWJHVnNUbGhTUmxwWVZrVm9kR1ZHYTNoVU1EVnJUVWR3ZFdNd05VVmFSVVo0Vm10NGRsVnJWa2haYkd4dVUyNXZlbEpxUW5WT1YxRjNXbGhyTkZKcVVqVmhibEpXVkVVNWNtSkdUbnBaYXpWWVUxZDNNMVpSdUFFQQ%3D%3D'
ytch.searchChannelMore(continuation).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
})
// Response object
{
items: Array[Object],
continuation: String // Will return null if no more results can be found. Used with searchChannelMore()
}
Tests
Tests and code standards are still in the process of being created. Check back later for information on how tests should be performed.
Contribution
PRs are welcome. Testing and coding guidlines are still in the works so I will try to get those created at a later point. Try to keep similar code syntax to the rest of the code.
Credits
This is a fork of the youtube-grabber-js
module created by OlegRom4ig
View the original project on NPM or GitLab
License
You have explicit permission to use this project as stated in the terms of the ISC license.