Documentation
Library Exports.Channel
A YouTube channel.
Constructors
constructor
• new Channel(youtube
, data
, full?
)
Parameters
Name | Type | Default value |
---|---|---|
youtube | YouTube | undefined |
data | any | undefined |
full | boolean | false |
Defined in
Properties
about
• about: string
The description of this channel.
Defined in
country
• country: string
The country this channel is based in.
Defined in
customUrl
• customUrl: string
This channel's custom URL, if they have one.
Defined in
data
• data: any
The raw data of this channel.
Defined in
dateCreated
• dateCreated: Date
The date this channel was created.
Defined in
featuredChannels
• featuredChannels: string
[]
The URLs of all of this channel's featured channels. This property is broken for some channels.
Defined in
full
• full: boolean
Whether or not this a full channel object.
Defined in
id
• id: string
The ID of this channel.
Defined in
keywords
• keywords: string
[]
This channel's keywords.
Defined in
kids
• kids: Object
Properties to do with videos made for children.
Type declaration
Name | Type | Description |
---|---|---|
madeForKids | boolean | Whether or not the channel is made for children. |
selfDeclaredMadeForKids | boolean | Whether or not the owner of the channel marked it as made for kids. |
Defined in
language
• language: string
The default language for this channel's uploads.
Defined in
liveStatus
• liveStatus: false
| "live"
| "upcoming"
Only set if the channel is a search result.
If the channel has an ongoing livestream, this is live
.
If the channel has an upcoming livestream, this is upcoming
.
If the channel has neither an ongoing nor upcoming livestream, this is false
.
Defined in
name
• name: string
The name of this channel.
Defined in
playlists
• playlists: PaginatedResponse
<Playlist
>
The channel's playlists. Only defined when Channel.fetchPlaylists is called.
Defined in
profilePictures
• profilePictures: Object
This channel's profile pictures.
Type declaration
Name | Type |
---|---|
default? | Thumbnail |
high? | Thumbnail |
maxres? | Thumbnail |
medium? | Thumbnail |
standard? | Thumbnail |
Defined in
sections
• sections: ChannelSection
[]
The channel's sections. Only defined when Channel.fetchSections is called.
Defined in
subCount
• subCount: number
The number of subscribers this channel has. -1
if the subcount is hidden.
Defined in
subscriptions
• subscriptions: PaginatedResponse
<Subscription
>
The channel's subscriptions. Only defined when Channel.fetchSubscriptions is called.
Defined in
url
• url: string
The url of the channel.
Defined in
videos
• videos: Playlist
The channel's uploads. Only available after calling Channel.fetchVideos
Defined in
views
• views: number
This channel's view count.
Defined in
youtube
• youtube: YouTube
The YouTube object that created this channel object.
Defined in
endpoint
▪ Static
endpoint: string
= 'channels'
The name of the endpoint used for this entity.
Defined in
fields
▪ Static
fields: string
The fields to request for this entity.
Defined in
part
▪ Static
part: string
= 'snippet,contentDetails,statistics,status,brandingSettings'
The parts to request for this entity.
Defined in
Methods
fetch
▸ fetch(parts?
): Promise
<Channel
>
Fetches this channel from the API and reassigns this object to the new channel object.
Only useful if this.full
is false, or if you want updated channel info.
Parameters
Name | Type |
---|---|
parts? | ChannelParts |
Returns
Promise
<Channel
>
Defined in
fetchPlaylists
▸ fetchPlaylists(pageOptions?
, parts?
): Promise
<PaginatedResponse
<Playlist
>>
Fetches the channel's playlists from the API and assigns them to Channel.playlists.
Parameters
Name | Type | Description |
---|---|---|
pageOptions? | PageOptions | The number of pages and maximum number of items per page. Fetches the maximum number of items allowed by the API per page by default. Set pages to a value <=0 to fetch all. |
parts? | PlaylistParts | The parts of the object to fetch (saves quota if you aren't using certain properties!) |
Returns
Promise
<PaginatedResponse
<Playlist
>>
Defined in
fetchSections
▸ fetchSections(parts?
): Promise
<ChannelSection
[]>
Fetches the channel's sections from the API and assigns them to Channel.sections.
Parameters
Name | Type |
---|---|
parts? | ChannelSectionParts |
Returns
Promise
<ChannelSection
[]>
Defined in
fetchSubscriptions
▸ fetchSubscriptions(pageOptions?
, parts?
): Promise
<PaginatedResponse
<Subscription
>>
Fetches the channel's subscriptions from the API and assigns them to Channel.subscriptions.
Parameters
Name | Type | Description |
---|---|---|
pageOptions? | PageOptions | The number of pages and maximum number of items per page. Fetches the maximum number of items allowed by the API per page by default. Set pages to a value <=0 to fetch all. |
parts? | SubscriptionParts | The parts of the object to fetch (saves quota if you aren't using certain properties!) |
Returns
Promise
<PaginatedResponse
<Subscription
>>
Defined in
fetchVideos
▸ fetchVideos(parts?
): Promise
<Playlist
>
Fetches the channel's playlist of uploads from the API and assigns it to the Channel.videos property.
Parameters
Name | Type |
---|---|
parts? | PlaylistParts |
Returns
Promise
<Playlist
>
Defined in
setBanner
▸ setBanner(image
): Promise
<Channel
>
Uploads and sets the channel's banner. Must be using an access token with correct scopes.
Parameters
Name | Type |
---|---|
image | Object |
image.data | Buffer |
image.type | "jpeg" | "png" |
Returns
Promise
<Channel
>
Defined in
setMadeForKids
▸ setMadeForKids(madeForKids
): Promise
<Channel
>
Sets whether or not the channel is made for kids. Must be using an access token with correct scopes.
Parameters
Name | Type |
---|---|
madeForKids | boolean |
Returns
Promise
<Channel
>
Defined in
setWatermark
▸ setWatermark(type
, offset
, duration
, image
): Promise
<void
>
Sets the channel's watermark. Must be using an access token with correct scopes.
Parameters
Name | Type |
---|---|
type | "fromStart" | "fromEnd" |
offset | number |
duration | number |
image | Image |
Returns
Promise
<void
>
Defined in
subscribe
▸ subscribe(): Promise
<Subscription
>
Subscribes to the channel. Must be using an access token with correct scopes.
Returns
Promise
<Subscription
>
Defined in
unsetWatermark
▸ unsetWatermark(): Promise
<void
>
Unsets the channel's watermark. Must be using an access token with correct scopes.
Returns
Promise
<void
>
Defined in
unsubscribe
▸ unsubscribe(subscriptionResolvable?
, myId?
): Promise
<void
>
Unsubscribes from the channel. Must be using an access token with correct scopes.
Parameters
Name | Type | Description |
---|---|---|
subscriptionResolvable? | SubscriptionResolvable | The ID or object of the subscription to remove, if you have it. |
myId? | string | The ID of the authorized channel, if you have it. |
Returns
Promise
<void
>
Defined in
updateBranding
▸ updateBranding(branding
): Promise
<Channel
>
Updates the channel's branding settings. Must be using an access token with correct scopes.
Parameters
Name | Type |
---|---|
branding | ChannelBrandingSettings |
Returns
Promise
<Channel
>
Defined in
updateLocalizations
▸ updateLocalizations(localizations
): Promise
<Channel
>
Updates the channel's localizations. Must be using an access token with correct scopes.
Parameters
Name | Type |
---|---|
localizations | Object |
Returns
Promise
<Channel
>