SpotifyApiSpotify LogoJS

PlaylistManager src/managers/Playlist.ts#L18

A manager to perform actions which belongs to the spotify playlist web api.


Properties:

client

Methods:

addItems create edit follow get getImages getTracks removeItems reorderItems unfollow uploadImage

constructor(client) src/managers/Playlist.ts#L18

No documentation found.

NameTypeDescription
clientClientThe spotify api client.

.client

Type:

Client

No documentation found.

.addItems(id, uris, position) src/managers/Playlist.ts#L105

Add items to the playlist. This method requires an user authorized token.

const snapshotID = await client.playlists.addItems('playlist id', [myTrack.uri, myAnotherTrack.uri, 'spotify:track:id']);

Returns:

Promise<string>

Parameters:

NameTypeDescription
idstringThe spotify playlist id.
urisstring[]The array of track or episodes uris to add.
positionnumberThe index position to add those items else will append it at the end of the playlist.
OPTIONAL

.create(userID, playlist) src/managers/Playlist.ts#L71

Create a playlist for a paticular user. This method requires an user authorized token.

const playlist = await client.playlists.create('id', { name: 'My Playlist' });

Returns:

Promise<"null" | Playlist>

Parameters:

NameTypeDescription
userIDstringThe spotify user id.
playlistCreatePlaylistQueryThe playlist details.

.edit(id, playlist) src/managers/Playlist.ts#L88

Edit a playlist. This method requires an user authorized token.

const playlist = await client.playlists.edit('id', { name: 'Edited playlist' });

Returns:

Promise<boolean>

Parameters:

NameTypeDescription
idstringThe playlist id.
playlistPartial<CreatePlaylistQuery>The details of the playlist to edit.

.follow(id, publicly) src/managers/Playlist.ts#L189

Follow the playlist. This method requires an user authorized token.

await client.playlists.follow('id');

Returns:

Promise<boolean>

Parameters:

NameTypeDescription
idstringThe spotify playlist id.
publiclybooleanIf true, the playlist will be in your list publicly.

.get(id, market, force) src/managers/Playlist.ts#L28

Get a playlist's information.

const playlist = await client.playlists.get('id');

Returns:

Promise<"null" | Playlist>

Parameters:

NameTypeDescription
idstringThe spotify playlist id.
marketstringOnly playlists that are available in that market will be returned.
forcebooleanWhen true, will directly fetch else will search for the cache first!

.getImages(id) src/managers/Playlist.ts#L59

Get the information of the images of the playlist.

const images = await client.playlists.getImages('id');

Returns:

Promise<Image[]>

Parameters:

NameTypeDescription
idstringThe spotify playlist id.

.getTracks(id, options) src/managers/Playlist.ts#L41

Get the information of the tracks in the playlist.

const tracks = await client.playlists.getTracks('id');

Returns:

Promise<PlaylistTrack[]>

Parameters:

NameTypeDescription
idstringThe spotify playlist id.
options{ limit?: number, market?: string, offset?: number, }The market, limit, offset query paramaters.

.removeItems(id, uris, snapshotID) src/managers/Playlist.ts#L150

Remove items from the playlist. This method requires an user authorized token.

const snapshotID = await client.playlists.removeItems('playlist id', { uris: ['spotify:uri:id']  });

Returns:

Promise<string>

Parameters:

NameTypeDescription
idstringThe spotify playlist id.
urisstring[]The array of spotify uris of either track or episodes to remove
snapshotIDstringThe playlist’s snapshot ID against which you want to make the changes.
OPTIONAL

.reorderItems(id, options) src/managers/Playlist.ts#L126

Reorder items in the playlist. This method requires an user authorized token.

const snapshotID = await client.playlists.reorderItems('playlist id', {
    uris: ['spotify:uri:id'],
    insertBefore: 2
});

Returns:

Promise<string>

Parameters:

NameTypeDescription
idstringThe spotify playlist id.
optionsPlaylistReorderOptionsThe options required to reorder items in the playlist.

.unfollow(id) src/managers/Playlist.ts#L204

Unfollow the playlist. This method requires an user authorized token.

await client.playlists.unfollow('id');

Returns:

Promise<boolean>

Parameters:

NameTypeDescription
idstringThe spotify playlist id.

.uploadImage(id, imageData) src/managers/Playlist.ts#L173

Upload custom images to the playlist. This method requires an user authorized token.

await client.playlists.uploadImage('id', 'data:image/jpeg;....');

Returns:

Promise<boolean>

Parameters:

NameTypeDescription
idstringThe spotify playlist id.
imageDatastringThe imageData should contain a Base64 encoded JPEG image data, maximum payload size is 256 KB.