PlaylistManager src/managers/Playlist.ts#L18
A manager to perform actions which belongs to the spotify playlist web api.
Properties:
clientMethods:
addItems create edit follow get getImages getTracks removeItems reorderItems unfollow uploadImageconstructor(client) src/managers/Playlist.ts#L18
No documentation found.
Name | Type | Description |
---|---|---|
client | Client | The spotify api client. |
.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:
Parameters:
Name | Type | Description |
---|---|---|
id | string | The spotify playlist id. |
uris | string[] | The array of track or episodes uris to add. |
position | number | The 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:
Parameters:
Name | Type | Description |
---|---|---|
userID | string | The spotify user id. |
playlist | CreatePlaylistQuery | The 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:
Parameters:
Name | Type | Description |
---|---|---|
id | string | The playlist id. |
playlist | Partial<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:
Parameters:
Name | Type | Description |
---|---|---|
id | string | The spotify playlist id. |
publicly | boolean | If 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:
Parameters:
Name | Type | Description |
---|---|---|
id | string | The spotify playlist id. |
market | string | Only playlists that are available in that market will be returned. |
force | boolean | When 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:
Parameters:
Name | Type | Description |
---|---|---|
id | string | The 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:
Parameters:
Name | Type | Description |
---|---|---|
id | string | The 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:
Parameters:
Name | Type | Description |
---|---|---|
id | string | The spotify playlist id. |
uris | string[] | The array of spotify uris of either track or episodes to remove |
snapshotID | string | The 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:
Parameters:
Name | Type | Description |
---|---|---|
id | string | The spotify playlist id. |
options | PlaylistReorderOptions | The 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:
Parameters:
Name | Type | Description |
---|---|---|
id | string | The 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:
Parameters:
Name | Type | Description |
---|---|---|
id | string | The spotify playlist id. |
imageData | string | The imageData should contain a Base64 encoded JPEG image data, maximum payload size is 256 KB. |