Skip to main content

Documentation

Library Exports.Playlist

A YouTube playlist.

Constructors

constructor

new Playlist(youtube, data, full?)

Parameters

NameTypeDefault value
youtubeYouTubeundefined
dataanyundefined
fullbooleanfalse

Defined in

entities/playlist.ts:112

Properties

creatorId

creatorId: string

The ID of the creator of the playlist.

Defined in

entities/playlist.ts:69


data

data: any

The raw data of this playlist.

Defined in

entities/playlist.ts:35


dateCreated

dateCreated: Date

The date the playlist was created.

Defined in

entities/playlist.ts:79


description

description: string

The description of the playlist.

Defined in

entities/playlist.ts:55


embedHtml

embedHtml: string

An \<iframe> tag that embeds a player that will play the playlist.

Defined in

entities/playlist.ts:100


full

full: boolean

Whether or not this is a full playlist object.

Defined in

entities/playlist.ts:40


id

id: string

The ID of this playlist.

Defined in

entities/playlist.ts:45


length

length: number

The number of items in the playlist.

Defined in

entities/playlist.ts:95


privacy

privacy: "private" | "public" | "unlisted"

Information on this playlist's privacy.

Defined in

entities/playlist.ts:110


tags

tags: string[]

The tags of the playlist.

Defined in

entities/playlist.ts:105


thumbnails

thumbnails: Object

The thumbnails for the playlist.

Type declaration

NameType
default?Thumbnail
high?Thumbnail
maxres?Thumbnail
medium?Thumbnail
standard?Thumbnail

Defined in

entities/playlist.ts:84


title

title: string

The title of the playlist.

Defined in

entities/playlist.ts:50


url

url: string

The url of the playlist.

Defined in

entities/playlist.ts:74


videos

videos: PaginatedResponse<Video>

The videos in the playlist. Only available after calling Playlist.fetchVideos().
These are partial, meaning they are missing some data. See the properties they include here. Use YouTube.getVideo(playlist.videos) to fetch the full objects while not spamming your quota like you would using a loop.

Defined in

entities/playlist.ts:64


youtube

youtube: YouTube

The YouTube object that created this playlist.

Defined in

entities/playlist.ts:30


endpoint

Static endpoint: string = 'playlists'

The name of the endpoint used for this entity.

Defined in

entities/playlist.ts:11


fields

Static fields: string

The fields to request for this entity.

Defined in

entities/playlist.ts:21


part

Static part: string = 'snippet,contentDetails,player,status'

The parts to request for this entity.

Defined in

entities/playlist.ts:16

Methods

addVideo

addVideo(videoResolvable, position?, note?): Promise<Video>

Adds a Video to the playlist. Must be using an access token with correct scopes.

Parameters

NameTypeDescription
videoResolvableVideoResolvableThe URL, ID, or search query of the video.
position?numberThe zero-based position to insert the video in.
note?stringA note on the video.

Returns

Promise<Video>

Defined in

entities/playlist.ts:201


delete

delete(): Promise<void>

Deletes the playlist. Must be using an access token with correct scopes.

Returns

Promise<void>

Defined in

entities/playlist.ts:274


fetch

fetch(parts?): Promise<Playlist>

Fetches this playlist from the API and reassigns this object to the new playlist object. Only useful if this.full is false, or if you want updated playlist info.

Parameters

NameType
parts?PlaylistParts

Returns

Promise<Playlist>

Defined in

entities/playlist.ts:170


fetchVideos

fetchVideos(pageOptions?, parts?): Promise<PaginatedResponse<Video>>

Fetches the videos in this playlist from the API and adds them to the videos property.
These are partial, meaning they are missing some data. See the properties they include here. Use YouTube.getVideo(playlist.videos) to fetch the full objects while not spamming your quota like you would using a loop.

Parameters

NameTypeDescription
pageOptions?PageOptionsThe 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?PlaylistItemPartsThe parts of the object to fetch (saves quota if you aren't using certain properties!)

Returns

Promise<PaginatedResponse<Video>>

Defined in

entities/playlist.ts:161


removeItem

removeItem(playlistItemId): Promise<void>

Removes a Video from the playlist. Must be using an access token with correct scopes.

Parameters

NameTypeDescription
playlistItemIdstringThe playlist item ID (not the same as video ID; see Playlist.removeVideo()).

Returns

Promise<void>

Defined in

entities/playlist.ts:258


removeVideo

removeVideo(videoResolvable): Promise<void>

Removes a Video from the playlist. Must be using an access token with correct scopes.

Parameters

NameTypeDescription
videoResolvableVideoResolvableThe URL, ID, or (not recommended) search query of the video.

Returns

Promise<void>

Defined in

entities/playlist.ts:240


update

update(title, description?, privacy?, tags?, language?, localizations?): Promise<Playlist>

Edits the playlist. Must be using an access token with correct scopes.
If your request does not specify a value for a property that already has a value, the property's existing value will be deleted.

Parameters

NameTypeDescription
titlestringA title for the playlist.
description?stringA description of the playlist.
privacy?"private" | "public" | "unlisted"Whether the video is private, public, or unlisted.
tags?string[]Tags pertaining to the playlist.
language?stringThe language of the playlist's default title and description.
localizations?ObjectTranslated titles and descriptions.

Returns

Promise<Playlist>

Defined in

entities/playlist.ts:187


updateVideo

updateVideo(videoResolvable, position?, note?, itemId?): Promise<Video>

Updates a Video in the playlist. Must be using an access token with correct scopes.

Parameters

NameTypeDescription
videoResolvableVideoResolvableThe URL, ID, or (not recommended) search query of the video.
position?numberThe zero-based position to move the video to.
note?stringA new note on the video.
itemId?stringThe playlist item ID if you have it.

Returns

Promise<Video>

Defined in

entities/playlist.ts:220