Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
yt-channel-info
Advanced tools
This library is designed to receive channel data from YouTube without accessing the official API.
This method has several advantages:
But there are also disadvantages:
You must consider this before you use YouTube Channel Info
npm i yt-channel-info --save
// If using require
const ytch = require('yt-channel-info')
// If using import
import ytch from 'yt-channel-info'
getChannelInfo(payload)
true
. Grabs top comments when false
0
= Default value used by the module. It will try all url types in the order channel -> user -> name1
= A channel id that is used with https://www.youtube.com/channel/channelId
urls2
= A user id that is used with https://www.youtube.com/user/channelId
urls3
= A name id that is used with https://www.youtube.com/c/channelId
urlsconst payload = {
channelId: 'UCXuqSBlHAE6Xw-yeJA0Tunw', // Required
channelIdType: 0,
httpsAgent: agent
}
ytch.getChannelInfo(payload).then((response) => {
if (!response.alertMessage) {
console.log(response)
} else {
console.log('Channel could not be found.')
// throw response.alertMessage
}
}).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: {
items: Array[Object],
continuation: String // Will return null if there are 12 or fewer related channels. Used with getRelatedChannelsMore()
},
allowedRegions: Array[String],
isVerified: Boolean,
isOfficialArtist: Boolean,
tags: Array[String], // Will return null if none exist
channelIdType: Number,
channelTabs: Array[String], // The tabs that are displayed on the channel (e.g., Videos, Playlists)
alertMessage: String, // Will return a response alert message if any (e.g., "This channel does not exist."). Otherwise undefined
channelLinks: {
primaryLinks: Array[Object],
secondaryLinks: Array[Object]
}
}
getChannelVideos(payload)
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)getChannelInfo()
getChannelInfo()
const payload = {
channelId: 'UCXuqSBlHAE6Xw-yeJA0Tunw', // Required
sortBy: 'newest',
channelIdType: 0
}
ytch.getChannelVideos(payload).then((response) => {
if (!response.alertMessage) {
console.log(response)
} else {
console.log('Channel could not be found.')
// throw response.alertMessage
}
}).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()
channelIdType: Number,
alertMessage: String, // Will return a response alert message if any (e.g., "This channel does not exist."). Otherwise undefined
}
getChannelVideosMore(payload)
Grabs more videos within a channel. Uses the continuation string returned from getChannelVideos()
or from past calls to getChannelVideosMore()
.
Grabs videos from a given channel ID.
getChannelVideos()
or from past calls to getChannelVideosMore()
.getChannelInfo()
const payload = {
continuation: '4qmFsgK9ARIYVUNYdXFTQmxIQUU2WHcteWVKQTBUdW53GqABRWdsd2JHRjViR2x6ZEhNZ0FYcG1VVlZzVUdFeGF6VlNiVkoyV1ZjNWJHVnNUbGhTUmxwWVZrVm9kR1ZHYTNoVU1EVnJUVWR3ZFdNd05VVmFSVVo0Vm10NGRsVnJWa2haYkd4dVUyNXZlbEpxUW5WT1YxRjNXbGhyTkZKcVVqVmhibEpXVkVVNWNtSkdUbnBaYXpWWVUxZDNNMVpSdUFFQQ%3D%3D', // Required
}
ytch.getChannelVideosMore(payload).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(payload)
Grabs playlist information of a given channel ID.
payload (Object) (Required)
- An object containing the various options
last
- Grabs playlists from a channel sorted by the most recently updated playlist (Default option if none given)oldest
- Grabs playlists from a channel sorted by the creation date (oldest first)newest
- Grabs playlists from a channel sorted by the creation date (newest first)getChannelInfo()
getChannelInfo()
const payload = {
channelId: 'UCXuqSBlHAE6Xw-yeJA0Tunw',
sortBy: 'last',
}
ytch.getChannelPlaylistInfo(payload).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()
channelIdType: Number,
}
getChannelPlaylistsMore(payload)
Grabs more playlists within a channel. Uses the continuation string returned from getChannelPlaylists()
or from past calls to getChannelPlaylistsMore()
.
getChannelPlaylists()
or from past calls to getChannelPlaylistsMore()
.getChannelInfo()
const payload = {
continuation: '4qmFsgK9ARIYVUNYdXFTQmxIQUU2WHcteWVKQTBUdW53GqABRWdsd2JHRjViR2x6ZEhNZ0FYcG1VVlZzVUdFeGF6VlNiVkoyV1ZjNWJHVnNUbGhTUmxwWVZrVm9kR1ZHYTNoVU1EVnJUVWR3ZFdNd05VVmFSVVo0Vm10NGRsVnJWa2haYkd4dVUyNXZlbEpxUW5WT1YxRjNXbGhyTkZKcVVqVmhibEpXVkVVNWNtSkdUbnBaYXpWWVUxZDNNMVpSdUFFQQ%3D%3D'
}
ytch.getChannelPlaylistsMore(payload).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(payload)
Searchs for videos and playlists of a given channelId based on the given query
getChannelInfo()
getChannelInfo()
const payload = {
channelId: 'UCXuqSBlHAE6Xw-yeJA0Tunw',
query: 'linux'
}
ytch.searchChannel(payload).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(payload)
Grabs more search results within a channel. Uses the continuation string returned from searchChannel()
or from past calls to searchChannelMore()
.
searchChannel()
or from past calls to searchChannelMore()
.getChannelInfo()
const payload = {
continuation: '4qmFsgK9ARIYVUNYdXFTQmxIQUU2WHcteWVKQTBUdW53GqABRWdsd2JHRjViR2x6ZEhNZ0FYcG1VVlZzVUdFeGF6VlNiVkoyV1ZjNWJHVnNUbGhTUmxwWVZrVm9kR1ZHYTNoVU1EVnJUVWR3ZFdNd05VVmFSVVo0Vm10NGRsVnJWa2haYkd4dVUyNXZlbEpxUW5WT1YxRjNXbGhyTkZKcVVqVmhibEpXVkVVNWNtSkdUbnBaYXpWWVUxZDNNMVpSdUFFQQ%3D%3D'
}
ytch.searchChannelMore(payload).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()
}
getRelatedChannelsMore(payload)
Grabs more related channels within a channel. Uses the relatedChannelsContinuation string returned from getChannelInfo()
or from past calls to getRelatedChannelsMore()
.
getChannelInfo()
or from past calls to getRelatedChannelsMore()
.getChannelInfo()
const payload = {
continuation: '4qmFsgKlARIYVUNtOUs2cmJ5OThXOEppZ0xvWk9oNkZRGlhFZ2hqYUdGdWJtVnNjeGdESUFBd0FUZ0I2Z01vUTJkQlUwZG9iMWxXVlU1M1pXdHNVR1ZzUW5saE1IaGhXWHBhWm1SV1NsSldWazQyVG5wa1VnJTNEJTNEmgIuYnJvd3NlLWZlZWRVQ205SzZyYnk5OFc4SmlnTG9aT2g2RlFjaGFubmVsczE1Ng%3D%3D'
}
ytch.getRelatedChannelsMore(payload).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 getRelatedChannelsMore()
}
getChannelCommunityPosts(payload)
Searches for all posts on the community page of a given channelId based on the given query.
getChannelInfo()
getChannelInfo()
const payload = {
channelId: 'UCXuqSBlHAE6Xw-yeJA0Tunw'
}
ytch.getChannelCommunityPosts(payload).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
})
// Response object
{
items: Array[Object], // Described below
continuation: String, // Will return null if no more results can be found. Used with searchChannelMore()
innerTubeApi: String,
channelIdType: Number,
}
getChannelStats(payload)
Gets the stats of a channel
channelIdType
in getChannelInfo()
getChannelInfo()
const payload = {
channelId: 'UCXuqSBlHAE6Xw-yeJA0Tunw'
}
ytch.getChannelStats(payload).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
})
// Response object
{
joinedDate: Integer, // Date joined in ms
viewCount: Integer, // Total views on channel
location: String // location of channel
}
getChannelCommunityPostsMore(payload)
Grabs more search results within a channel community page. Uses the continuation and innerTubeApi strings returned from getChannelCommunityPosts()
or from past calls to getChannelCommunityPostsMore()
.
getChannelCommunityPosts()
or from past calls to getChannelCommunityPostsMore()
.getChannelCommunityPosts()
or from past calls to getChannelCommunityPostsMore()
.getChannelInfo()
const payload = {
continuation: '4qmFsgK9ARIYVUNYdXFTQmxIQUU2WHcteWVKQTBUdW53GqABRWdsd2JHRjViR2x6ZEhNZ0FYcG1VVlZzVUdFeGF6VlNiVkoyV1ZjNWJHVnNUbGhTUmxwWVZrVm9kR1ZHYTNoVU1EVnJUVWR3ZFdNd05VVmFSVVo0Vm10NGRsVnJWa2haYkd4dVUyNXZlbEpxUW5WT1YxRjNXbGhyTkZKcVVqVmhibEpXVkVVNWNtSkdUbnBaYXpWWVUxZDNNMVpSdUFFQQ%3D%3D',
innerTubeApi: 'JNDJSGJHASJ44DSHGDNLGMHA6FSFas5faF5'
}
ytch.getChannelCommunityPostsMore(payload).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
})
// Response object
{
items: Array[Object], // Described below
continuation: String, // Will return null if no more results can be found. Used with searchChannelMore()
innerTubeApi: String
}
getChannelHome(payload)
Searchs for videos and playlists of a given channelId based on the given query
getChannelInfo()
getChannelInfo()
const payload = {
channelId: 'UCXuqSBlHAE6Xw-yeJA0Tunw',
}
ytch.getChannelHome(payload).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
})
// Response object
{
featuredVideo: {
type: 'video',
title: String,
videoId: String,
author: String,
authorId: String,
videoThumbnails: [],
viewCountText: String,
viewCount: Number,
publishedText: String,
durationText: undefined,
lengthSeconds: 0,
liveNow: Boolean,
premier: Boolean,
premium: Boolean
},
items: Array[Object],
}
Community Posts Format
The objects in the array of community posts all follow a basic structure but vary drastically in the postContent field of the object.
-httpsAgent
defined as for getChannelInfo()
postData = {
postText: String,
postId: String,
author: String,
authorThumbnails: Array[Object], // Array of objects with links to images
publishedText: String,
voteCount: String,
postContent: Object, // null if the post only consists of text
commentCount: String
}
// If the post contains an image
imagePostContent = {
type: 'image',
content: Array[Object] // Array of objects with links to images
}
pollPostContent = {
type: 'poll',
content: {
choices: Array[String],
totalVotes: String
}
}
videoPostContent = {
type: 'video',
content: {
videoId: String,
title: String,
description: String,
publishedText: String,
lengthText: String,
viewCountText: String,
ownerBadges: Object, // Object indicating possible badges {verified: false, officialArtist: false}
author: String,
thumbnails: Array[Object] // Array of objects with links to images
}
}
playlistPostContent = {
type: 'playlist',
content: {
playlistId: String,
title: String,
playlistVideoRenderer: Array[Object], // An array of minimized videoPostContent data
videoCountText: String,
ownerBadges: Array[Object],
author: String,
thumbnails: Array[Object] // Array of objects with links to images
}
}
In order to use a proxy, you have to provide an assembled HTTP Agent. This can be achieved via additional packages like https-proxy-agent:
import HttpsProxyAgent from 'https-proxy-agent';
const proxy = 'http://127.0.0.1:10003';
const httpAgent = HttpsProxyAgent(proxy);
Tests and code standards are still in the process of being created. Check back later for information on how tests should be performed.
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.
This is a fork of the youtube-grabber-js
module created by OlegRom4ig
View the original project on NPM or GitLab
You have explicit permission to use this project as stated in the terms of the ISC license.
FAQs
Grab YouTube channel information without any official API
We found that yt-channel-info demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.