Skip to content

Latest commit

 

History

History
1058 lines (533 loc) · 24.8 KB

DOCUMENTATION.md

File metadata and controls

1058 lines (533 loc) · 24.8 KB

youtube-music-ts-apiDocs


interfaces-primary

Index

Interfaces

youtube-music-ts-apiDocs


Interface: IYouTubeMusic

Defines the main YouTube Music API object. Using this object, you can either choose to make calls as a guest or an authenticated user. Not all APIs are available as a guest, so it is preferred to authenticate the user if possible.

Methods

authenticate()

authenticate(cookiesStr, authUser): Promise<IYouTubeMusicAuthenticated>

Authenticates the user with the YouTube Music API. This function overload requies the cookie string of a valid logged in user.

Parameters

cookiesStr: string

The cookie string of a valid logged in user. To obtain this cookie value, log into https://music.youtube.com as a user and use your browser's developer tools to obtain the "cookie" value sent as a request header. Extra values in the cookie will be ignored.

authUser: number

X-Goog-AuthUser header value

Returns

Promise<IYouTubeMusicAuthenticated>

A promise that will yield authenticated access to the YouTube Music API.

Defined in

interfaces-primary.ts:16


guest()

guest(): Promise<IYouTubeMusicGuest>

Provides guest access to the YouTube Music API. Only non-restrictive APIs (such as public playlists) are available to guests.

Returns

Promise<IYouTubeMusicGuest>

A promise that will yield guest access to the YouTube Music API.

Defined in

interfaces-primary.ts:23

youtube-music-ts-apiDocs


Interface: IYouTubeMusicAuthenticated

Defines the YouTube Music APIs available to an authenticated user. An authenticated user also naturally includes the APIs available to a guest.

Extends

Methods

addTracksToPlaylist()

addTracksToPlaylist(playlistId, ...tracks): Promise<boolean>

Adds the tracks to the specified playlist.

Parameters

playlistId: string

The ID of the playlist to add the tracks to.

• ...tracks: ITrackDetail[]

The array of tracks to add to the playlist.

Returns

Promise<boolean>

A promise that will yield whether or not the operation was successful.

Defined in

interfaces-primary.ts:37


createPlaylist()

createPlaylist(name, description?, privacy?, sourcePlaylistId?): Promise<IPlaylistSummary>

Creates a playlist in the user's library.

Parameters

name: string

The name of the playlist to create.

description?: string

An optional description for the playlist.

privacy?: string

An optional privacy level for the playlist (either PUBLIC, PRIVATE, or UNLISTED).

sourcePlaylistId?: string

An optional playlist ID to copy the initial set of tracks from.

Returns

Promise<IPlaylistSummary>

A promise that will yield the playlist with its ID.

Defined in

interfaces-primary.ts:48


deletePlaylist()

deletePlaylist(playlistId): Promise<boolean>

Deletes a playlist from the user's library.

Parameters

playlistId: string

The ID of the playlist to delete.

Returns

Promise<boolean>

A promise that will yield whether or not the operation was successful.

Defined in

interfaces-primary.ts:56


getAlbum()

getAlbum(id): Promise<IAlbumDetail>

Gets detailed information for a specific album.

Parameters

id: string

The ID of the album to get the detailed information for.

Returns

Promise<IAlbumDetail>

A promise that will yield the detailed information for a specific album.

Inherited from

IYouTubeMusicGuest.getAlbum

Defined in

interfaces-primary.ts:132


getLibraryAlbums()

getLibraryAlbums(): Promise<IAlbumSummary[]>

Gets all the albums in the user's library.

Returns

Promise<IAlbumSummary[]>

A promise that will yield an array of all the albums in the user's library.

Defined in

interfaces-primary.ts:63


getLibraryArtists()

getLibraryArtists(): Promise<IArtistSummary[]>

Gets all the artists in the user's library.

Returns

Promise<IArtistSummary[]>

A promise that will yield an array of all the artists in the user's library.

Defined in

interfaces-primary.ts:70


getLibraryHistory()

getLibraryHistory(): Promise<IPlaylistDetail>

Gets recently played tracks, in reverse chronological order, from the user's library

Returns

Promise<IPlaylistDetail>

A promise that will yield a playlist with detailed information on a recently played tracks.

Defined in

interfaces-primary.ts:91


getLibraryPlaylists()

getLibraryPlaylists(): Promise<IPlaylistSummary[]>

Gets all the playlists in the user's library.

Returns

Promise<IPlaylistSummary[]>

A promise that will yield an array of all the playlists in the user's library.

Defined in

interfaces-primary.ts:77


getLibraryTracks()

getLibraryTracks(): Promise<ITrackDetail[]>

Gets all the tracks in the user's library.

Returns

Promise<ITrackDetail[]>

A promise that will yield an array of all the tracks in the user's library.

Defined in

interfaces-primary.ts:84


getPlaylist()

getPlaylist(id, maxRetries?): Promise<IPlaylistDetail>

Gets detailed information for a specific playlist.

Parameters

id: string

The ID of the playlist to get the detailed information for.

maxRetries?: number

An optional maximum number of retries to obtain the tracks. YouTube Music is incredibly buggy in that not all tracks will be returned in a single request. If the request is retried, you may get a different set of tracks in the response. If you retry enough times, you will eventually get all the tracks (a union operation is done internally between all the tracks returned from each individual request).

Returns

Promise<IPlaylistDetail>

A promise that will yield the detailed information for a specific playlist.

Inherited from

IYouTubeMusicGuest.getPlaylist

Defined in

interfaces-primary.ts:145


moveTrackWithinPlaylist()

moveTrackWithinPlaylist(playlistId, trackToMove, trackToMoveBefore?): Promise<boolean>

Moves the specified track within the playlist.

Parameters

playlistId: string

The ID of the playlist to move the track within.

trackToMove: ITrackDetail

The track that should be moved.

trackToMoveBefore?: ITrackDetail

An optional track to move the track before. If unspecified, the track will be moved to the end of the playlist.

Returns

Promise<boolean>

A promise that will yield whether or not the operation was successful.

Defined in

interfaces-primary.ts:101


rateTrack()

rateTrack(trackId, rating): Promise<boolean>

Rates a track ("thumbs up"/"thumbs down" interaction).

Parameters

trackId: string

The ID of the track to rate.

rating: "LIKE" | "DISLIKE" | "INDIFFERENT"

One of 'LIKE', 'DISLIKE', or 'INDIFFERENT'. 'INDIFFERENT' removes the previous rating and assigns no rating.

Returns

Promise<boolean>

A promise that will yield whether or not the operation was successful.

Defined in

interfaces-primary.ts:119


removeTracksFromPlaylist()

removeTracksFromPlaylist(playlistId, ...tracks): Promise<boolean>

Removes the tracks from the specified playlist.

Parameters

playlistId: string

The ID of the playlist to remove the tracks from.

• ...tracks: ITrackDetail[]

The array of tracks to remove from the playlist.

Returns

Promise<boolean>

A promise that will yield whether or not the operation was successful.

Defined in

interfaces-primary.ts:110

youtube-music-ts-apiDocs


Interface: IYouTubeMusicGuest

Defines the YouTube Music APIs available to a guest.

Extended by

Methods

getAlbum()

getAlbum(id): Promise<IAlbumDetail>

Gets detailed information for a specific album.

Parameters

id: string

The ID of the album to get the detailed information for.

Returns

Promise<IAlbumDetail>

A promise that will yield the detailed information for a specific album.

Defined in

interfaces-primary.ts:132


getPlaylist()

getPlaylist(id, maxRetries?): Promise<IPlaylistDetail>

Gets detailed information for a specific playlist.

Parameters

id: string

The ID of the playlist to get the detailed information for.

maxRetries?: number

An optional maximum number of retries to obtain the tracks. YouTube Music is incredibly buggy in that not all tracks will be returned in a single request. If the request is retried, you may get a different set of tracks in the response. If you retry enough times, you will eventually get all the tracks (a union operation is done internally between all the tracks returned from each individual request).

Returns

Promise<IPlaylistDetail>

A promise that will yield the detailed information for a specific playlist.

Defined in

interfaces-primary.ts:145

youtube-music-ts-apiDocs


interfaces-supplementary

Index

Interfaces

youtube-music-ts-apiDocs


Interface: IAlbumDetail

Defines the details for an album.

Properties

artists?

optional artists: IArtistSummary[]

The artist(s) that composed the album.

Defined in

interfaces-supplementary.ts:33


count?

optional count: number

The count of tracks within the album.

Defined in

interfaces-supplementary.ts:23


description?

optional description: string

The description of the album.

Defined in

interfaces-supplementary.ts:18


durationMillis?

optional durationMillis: number

The duration of the album in milliseconds.

Defined in

interfaces-supplementary.ts:28


id?

optional id: string

The ID of the album.

Defined in

interfaces-supplementary.ts:8


name?

optional name: string

The name of the album.

Defined in

interfaces-supplementary.ts:13


releaseDay?

optional releaseDay: number

The day the album was released.

Defined in

interfaces-supplementary.ts:38


releaseMonth?

optional releaseMonth: number

The month the album was released.

Defined in

interfaces-supplementary.ts:43


releaseYear?

optional releaseYear: number

The year the album was released.

Defined in

interfaces-supplementary.ts:48


tracks

tracks: ITrackDetail[]

The array of tracks within the album.

Defined in

interfaces-supplementary.ts:53

youtube-music-ts-apiDocs


Interface: IAlbumSummary

Defines an album summary.

Properties

artist?

optional artist: IArtistSummary

The artist that composed the album.

Defined in

interfaces-supplementary.ts:73


id?

optional id: string

The ID of the album.

Defined in

interfaces-supplementary.ts:63


name?

optional name: string

The name of the album.

Defined in

interfaces-supplementary.ts:68


year?

optional year: string

The year the album was released.

Defined in

interfaces-supplementary.ts:78

youtube-music-ts-apiDocs


Interface: IArtistSummary

Defines an artist summary.

Properties

id?

optional id: string

The ID of the artist.

Defined in

interfaces-supplementary.ts:88


name?

optional name: string

The name of the artist.

Defined in

interfaces-supplementary.ts:93

youtube-music-ts-apiDocs


Interface: IPlaylistDetail

Defines the details for a playlist.

Properties

count?

optional count: number

The count of tracks within the playlist.

Defined in

interfaces-supplementary.ts:118


description?

optional description: string

The description of the playlist.

Defined in

interfaces-supplementary.ts:113


id?

optional id: string

The ID of the playlist.

Defined in

interfaces-supplementary.ts:103


name?

optional name: string

The name of the playlist.

Defined in

interfaces-supplementary.ts:108


privacy?

optional privacy: string

The privacy level of the playlist. This value will be PUBLIC, PRIVATE, or UNLISTED.

Defined in

interfaces-supplementary.ts:123


tracks?

optional tracks: ITrackDetail[]

The array of tracks within the playlist.

Defined in

interfaces-supplementary.ts:128

youtube-music-ts-apiDocs


Interface: IPlaylistSummary

Defines a playlist summary.

Properties

count?

optional count: number

The count of tracks within the playlist.

Defined in

interfaces-supplementary.ts:148


id?

optional id: string

The ID of the playlist.

Defined in

interfaces-supplementary.ts:138


name?

optional name: string

The name of the playlist.

Defined in

interfaces-supplementary.ts:143


thumbnails?

optional thumbnails: IThumbnail[]

The thumbnails for the playlist (ordered from smallest to largest).

Defined in

interfaces-supplementary.ts:153

youtube-music-ts-apiDocs


Interface: IThumbnail

Defines the details for a thumbnail.

Properties

height?

optional height: number

The height of the thumbnail.

Defined in

interfaces-supplementary.ts:229


url?

optional url: string

The URL for the thumbnail.

Defined in

interfaces-supplementary.ts:219


width?

optional width: number

The width of the thumbnail.

Defined in

interfaces-supplementary.ts:224

youtube-music-ts-apiDocs


Interface: ITrackDetail

Defines the details for a track.

Properties

album?

optional album: IAlbumSummary

The album the track is from.

Defined in

interfaces-supplementary.ts:184


alternateId?

optional alternateId: string

An alternate ID of the track. YouTube internally refers to this value as the setVideoId. This ID is used in combination with the standard ID in order to remove tracks from playlists.

Defined in

interfaces-supplementary.ts:169


artists?

optional artists: IArtistSummary[]

The artist(s) that compose the track.

Defined in

interfaces-supplementary.ts:179


duration?

optional duration: string

The duration of the track as a readable string.

Defined in

interfaces-supplementary.ts:189


durationMillis?

optional durationMillis: number

The duration of the track in milliseconds.

Defined in

interfaces-supplementary.ts:194


id?

optional id: string

The ID of the track.

Defined in

interfaces-supplementary.ts:163


likeStatus?

optional likeStatus: "LIKE" | "DISLIKE" | "INDIFFERENT"

The rating for the track (LIKE, DISLIKE, or INDIFFERENT).

Defined in

interfaces-supplementary.ts:209


thumbnails?

optional thumbnails: IThumbnail[]

The thumbnails for the track (ordered from smallest to largest).

Defined in

interfaces-supplementary.ts:204


title?

optional title: string

The title of the track.

Defined in

interfaces-supplementary.ts:174


trackNumber?

optional trackNumber: number

The track number within an album.

Defined in

interfaces-supplementary.ts:199