Skip to main content

Documentation

Library Exports.Video

A YouTube video.

Constructors

constructor

new Video(youtube, data, full?)

Parameters

NameTypeDefault value
youtubeYouTubeundefined
dataanyundefined
fullbooleanfalse

Defined in

entities/video.ts:185

Properties

captions

captions: Caption[]

The caption data associated with this video. Only available after running Video.fetchCaptions.

Defined in

entities/video.ts:178


category

category: string

The video category associated with the video.

Defined in

entities/video.ts:158


channel

channel: Object

Information on the channel that uploaded the video.

Type declaration

NameType
idstring
namestring

Defined in

entities/video.ts:84


commentCount

commentCount: number

The number of comments on the video.

Defined in

entities/video.ts:146


comments

comments: PaginatedResponse<Comment>

The video's comments. Only defined when Video.fetchComments is called.

Defined in

entities/video.ts:141


data

data: any

The raw data of the video.

Defined in

entities/video.ts:38


datePublished

datePublished: Date

The date the video was published.

Defined in

entities/video.ts:79


description

description: string

The description of the video.

Defined in

entities/video.ts:58


dislikes

dislikes: number

The number of dislikes the video has.

Defined in

entities/video.ts:122


full

full: boolean

Whether or not this is a full video object (would it be the same if we ran Video.fetch under the same conditions as last time?).

Defined in

entities/video.ts:43


id

id: string

The ID of the video.

Defined in

entities/video.ts:48


kids

kids: Object

Properties to do with videos made for children.

Type declaration

NameTypeDescription
madeForKidsbooleanWhether or not the video was made for children.
selfDeclaredMadeForKidsbooleanWhether or not the poster of the video marked it as made for kids.

Defined in

entities/video.ts:163


likes

likes: number

The number of likes the video has.

Defined in

entities/video.ts:117


liveStatus

liveStatus: false | "live" | "upcoming"

If this is a ongoing livestream, this is live. If this is an upcoming livestream, this is upcoming. If this is not a livestream, this is false.

Defined in

entities/video.ts:153


minutes

minutes: number

The minutes of the video.

Defined in

entities/video.ts:97


note

note: string

If this video was fetched from a playlist, this can be populated with a user-created note about the video.

Defined in

entities/video.ts:183


private

private: boolean

Whether or not this video COULD BE private. True if the video might be private, as you cannot check if playlist items are private.

I would recommend that you try and fetch the video and catch an error if it is from a playlist & marked as private.

Defined in

entities/video.ts:136


seconds

seconds: number

The seconds of the video.

Defined in

entities/video.ts:102


shortUrl

shortUrl: string

The short url of the video, i.e. https://youtu.be/id

Defined in

entities/video.ts:112


tags

tags: string[]

The tags of the video.

Defined in

entities/video.ts:74


thumbnails

thumbnails: Object

The thumbnails of the video.

Type declaration

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

Defined in

entities/video.ts:63


title

title: string

The title of the video.

Defined in

entities/video.ts:53


url

url: string

The url of the video.

Defined in

entities/video.ts:107


views

views: number

The number of views the video has.

Defined in

entities/video.ts:127


youtube

youtube: YouTube

YouTube object that created the video.

Defined in

entities/video.ts:33


endpoint

Static endpoint: string = 'videos'

The name of the endpoint used for this entity.

Defined in

entities/video.ts:14


fields

Static fields: string

The fields to request for this entity.

Defined in

entities/video.ts:24


part

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

The parts to request for this entity.

Defined in

entities/video.ts:19

Methods

delete

delete(): Promise<void>

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

Returns

Promise<void>

Defined in

entities/video.ts:338


dislike

dislike(): Promise<void>

Dislikes the video. Must be using an access token with correct scopes.

Returns

Promise<void>

Defined in

entities/video.ts:310


fetch

fetch(parts?): Promise<Video>

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

Parameters

NameType
parts?VideoParts

Returns

Promise<Video>

Defined in

entities/video.ts:272


fetchCaptions

fetchCaptions(): Promise<Caption[]>

Fetches the captions for the video from the API. Must be using an access token with correct scopes.

Returns

Promise<Caption[]>

Defined in

entities/video.ts:368


fetchComments

fetchComments(pageOptions?, order?, parts?): Promise<PaginatedResponse<Comment>>

Fetches the video's comments from the API and assigns them to Video.comments.

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.
order?"time" | "relevance"-
parts?CommentThreadPartsThe parts of the object to fetch (saves quota if you aren't using certain properties!)

Returns

Promise<PaginatedResponse<Comment>>

Defined in

entities/video.ts:284


getRating

getRating(): Promise<"none" | "like" | "dislike" | "unspecified">

Gets the user's rating on the video. Must be using an access token with correct scopes.

Returns

Promise<"none" | "like" | "dislike" | "unspecified">

Defined in

entities/video.ts:293


like

like(): Promise<void>

Likes the video. Must be using an access token with correct scopes.

Returns

Promise<void>

Defined in

entities/video.ts:302


postComment

postComment(text): Promise<Comment>

Posts a comment to the video. Must be using an access token with correct scopes.

Parameters

NameTypeDescription
textstringThe text of the comment.

Returns

Promise<Comment>

Defined in

entities/video.ts:259


reportAbuse

reportAbuse(reasonId, secondaryReasonId?, comments?, language?): Promise<void>

Reports the video for abuse. Must be using an access token with correct scopes.

Parameters

NameTypeDescription
reasonIdstringThe reason for reporting. (IDs can be found here)
secondaryReasonId?stringAn optional second reason for reporting.
comments?stringAny additional information.
language?stringThe language that the reporter speaks.

Returns

Promise<void>

Defined in

entities/video.ts:330


setThumbnail

setThumbnail(image): Promise<{ default?: Thumbnail ; high?: Thumbnail ; maxres?: Thumbnail ; medium?: Thumbnail ; standard?: Thumbnail }>

Sets a new thumbnail for a video. Must be using an access token with correct scopes.

Parameters

NameTypeDescription
imageObjectThe image data and type to upload.
image.dataBuffer-
image.type"jpeg" | "png"-

Returns

Promise<{ default?: Thumbnail ; high?: Thumbnail ; maxres?: Thumbnail ; medium?: Thumbnail ; standard?: Thumbnail }>

Defined in

entities/video.ts:359


unrate

unrate(): Promise<void>

Removes the user's like/dislike on the video. Must be using an access token with correct scopes.

Returns

Promise<void>

Defined in

entities/video.ts:318


update

update(video): Promise<Video>

Edits the video. 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
videoVideoUpdateResourceThe updated video object.

Returns

Promise<Video>

Defined in

entities/video.ts:349


updateCaption

updateCaption(track, draft?): Promise<Caption>

Updates a caption track of a video. Must be using an access token with correct scopes.

Parameters

NameTypeDefault valueDescription
trackBufferundefinedThe modified caption track to upload.
draftbooleannullWhether or not the track is a draft.

Returns

Promise<Caption>

Defined in

entities/video.ts:392


uploadCaption

uploadCaption(language, name, track, draft?): Promise<Caption>

Uploads a caption track for a video. Must be using an access token with correct scopes.

Parameters

NameTypeDefault valueDescription
languagestringundefinedThe language of the track.
namestringundefinedThe name of the track.
trackBufferundefinedThe caption track to upload.
draftbooleanfalseWhether or not the track is a draft.

Returns

Promise<Caption>

Defined in

entities/video.ts:381