Back to Top

spotify-web-api-js 1.5.2

A client-side JS wrapper for the Spotify Web API

SpotifyWebApi()

Class representing the API

Returns

Void

Constr()

Creates an instance of the wrapper

Returns

Void

Constr.getGeneric(url, callback)

Fetches a resource through a generic GET request.

Parameters

Name Type Description
url string

The URL to be fetched

callback function(Object, Object)

An optional callback

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getMe(options, callback)

Fetches information about the current user. See Get Current User's Profile on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getMySavedTracks(options, callback)

Fetches current user's saved tracks. See Get Current User's Saved Tracks on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.addToMySavedTracks(trackIds, options, callback)

Adds a list of tracks to the current user's saved tracks. See Save Tracks for Current User on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
trackIds Array.<string>

The ids of the tracks. If you know their Spotify URI it is easy to find their track id (e.g. spotify:track:<here_is_the_track_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.removeFromMySavedTracks(trackIds, options, callback)

Remove a list of tracks from the current user's saved tracks. See Remove Tracks for Current User on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
trackIds Array.<string>

The ids of the tracks. If you know their Spotify URI it is easy to find their track id (e.g. spotify:track:<here_is_the_track_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.containsMySavedTracks(trackIds, options, callback)

Checks if the current user's saved tracks contains a certain list of tracks. See Check Current User's Saved Tracks on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
trackIds Array.<string>

The ids of the tracks. If you know their Spotify URI it is easy to find their track id (e.g. spotify:track:<here_is_the_track_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getMySavedAlbums(options, callback)

Get a list of the albums saved in the current Spotify user's "Your Music" library. See Get Current User's Saved Albums on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.addToMySavedAlbums(albumIds, options, callback)

Save one or more albums to the current user's "Your Music" library. See Save Albums for Current User on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
albumIds Array.<string>

The ids of the albums. If you know their Spotify URI, it is easy to find their album id (e.g. spotify:album:<here_is_the_album_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.removeFromMySavedAlbums(albumIds, options, callback)

Remove one or more albums from the current user's "Your Music" library. See Remove Albums for Current User on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
albumIds Array.<string>

The ids of the albums. If you know their Spotify URI, it is easy to find their album id (e.g. spotify:album:<here_is_the_album_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.containsMySavedAlbums(albumIds, options, callback)

Check if one or more albums is already saved in the current Spotify user's "Your Music" library. See Check User's Saved Albums on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
albumIds Array.<string>

The ids of the albums. If you know their Spotify URI, it is easy to find their album id (e.g. spotify:album:<here_is_the_album_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getMyTopArtists(options, callback)

Get the current user’s top artists based on calculated affinity. See Get a User’s Top Artists on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getMyTopTracks(options, callback)

Get the current user’s top tracks based on calculated affinity. See Get a User’s Top Tracks on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getMyRecentlyPlayedTracks(options, callback)

Get tracks from the current user’s recently played tracks. See Get Current User’s Recently Played Tracks on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.followUsers(userIds, callback)

Adds the current user as a follower of one or more other Spotify users. See Follow Artists or Users on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
userIds Array.<string>

The ids of the users. If you know their Spotify URI it is easy to find their user id (e.g. spotify:user:<here_is_the_user_id>)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is an empty value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.followArtists(artistIds, callback)

Adds the current user as a follower of one or more artists. See Follow Artists or Users on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
artistIds Array.<string>

The ids of the artists. If you know their Spotify URI it is easy to find their artist id (e.g. spotify:artist:<here_is_the_artist_id>)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is an empty value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.followPlaylist(playlistId, options, callback)

Add the current user as a follower of one playlist. See Follow a Playlist on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

options Object

A JSON object with options that can be passed. For instance, whether you want the playlist to be followed privately ({public: false})

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is an empty value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.unfollowUsers(userIds, callback)

Removes the current user as a follower of one or more other Spotify users. See Unfollow Artists or Users on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
userIds Array.<string>

The ids of the users. If you know their Spotify URI it is easy to find their user id (e.g. spotify:user:<here_is_the_user_id>)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is an empty value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.unfollowArtists(artistIds, callback)

Removes the current user as a follower of one or more artists. See Unfollow Artists or Users on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
artistIds Array.<string>

The ids of the artists. If you know their Spotify URI it is easy to find their artist id (e.g. spotify:artist:<here_is_the_artist_id>)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is an empty value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.unfollowPlaylist(playlistId, callback)

Remove the current user as a follower of one playlist. See Unfollow a Playlist on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is an empty value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.isFollowingUsers(userIds, callback)

Checks to see if the current user is following one or more other Spotify users. See Check if Current User Follows Users or Artists on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
userIds Array.<string>

The ids of the users. If you know their Spotify URI it is easy to find their user id (e.g. spotify:user:<here_is_the_user_id>)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is an array of boolean values that indicate whether the user is following the users sent in the request.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.isFollowingArtists(artistIds, callback)

Checks to see if the current user is following one or more artists. See Check if Current User Follows on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
artistIds Array.<string>

The ids of the artists. If you know their Spotify URI it is easy to find their artist id (e.g. spotify:artist:<here_is_the_artist_id>)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is an array of boolean values that indicate whether the user is following the artists sent in the request.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.areFollowingPlaylist(playlistId, userIds, callback)

Check to see if one or more Spotify users are following a specified playlist. See Check if Users Follow a Playlist on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

userIds Array.<string>

The ids of the users. If you know their Spotify URI it is easy to find their user id (e.g. spotify:user:<here_is_the_user_id>)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is an array of boolean values that indicate whether the users are following the playlist sent in the request.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getFollowedArtists([options], callback)

Get the current user's followed artists. See Get User's Followed Artists on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

Options, being after and limit.

Optional
callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is an object with a paged object containing artists.

Returns

Promise

A promise that if successful, resolves to an object containing a paging object which contains artists objects. Not returned if a callback is given.

Constr.getUser(userId, options, callback)

Fetches information about a specific user. See Get a User's Profile on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
userId string

The id of the user. If you know the Spotify URI it is easy to find the id (e.g. spotify:user:<here_is_the_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getUserPlaylists(userId, options, callback)

Fetches a list of the current user's playlists. See Get a List of a User's Playlists on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
userId string

An optional id of the user. If you know the Spotify URI it is easy to find the id (e.g. spotify:user:<here_is_the_id>). If not provided, the id of the user that granted the permissions will be used.

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getPlaylist(playlistId, options, callback)

Fetches a specific playlist. See Get a Playlist on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getPlaylistTracks(playlistId, options, callback)

Fetches the tracks from a specific playlist. See Get a Playlist's Tracks on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getPlaylistCoverImage(playlistId, callback)

Gets the current image associated with a specific playlist. See Get a Playlist Cover Image on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:playlist:<here_is_the_playlist_id>)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.createPlaylist(userId, options, callback)

Creates a playlist and stores it in the current user's library. See Create a Playlist on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
userId string

The id of the user. If you know the Spotify URI it is easy to find the id (e.g. spotify:user:<here_is_the_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.changePlaylistDetails(playlistId, data, callback)

Change a playlist's name and public/private state See Change a Playlist's Details on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

data Object

A JSON object with the data to update. E.g. {name: 'A new name', public: true}

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.addTracksToPlaylist(playlistId, uris, options, callback)

Add tracks to a playlist. See Add Tracks to a Playlist on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

uris Array.<string>

An array of Spotify URIs for the tracks

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.replaceTracksInPlaylist(playlistId, uris, callback)

Replace the tracks of a playlist See Replace a Playlist's Tracks on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

uris Array.<string>

An array of Spotify URIs for the tracks

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.reorderTracksInPlaylist(playlistId, rangeStart, insertBefore, options, callback)

Reorder tracks in a playlist See Reorder a Playlist’s Tracks on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

rangeStart number

The position of the first track to be reordered.

insertBefore number

The position where the tracks should be inserted. To reorder the tracks to the end of the playlist, simply set insert_before to the position after the last track.

options Object

An object with optional parameters (range_length, snapshot_id)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.removeTracksFromPlaylist(playlistId, uris, callback)

Remove tracks from a playlist See Remove Tracks from a Playlist on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

uris Array.<Object>

An array of tracks to be removed. Each element of the array can be either a string, in which case it is treated as a URI, or an object containing the properties uri (which is a string) and positions (which is an array of integers).

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.removeTracksFromPlaylistWithSnapshotId(playlistId, uris, snapshotId, callback)

Remove tracks from a playlist, specifying a snapshot id. See Remove Tracks from a Playlist on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

uris Array.<Object>

An array of tracks to be removed. Each element of the array can be either a string, in which case it is treated as a URI, or an object containing the properties uri (which is a string) and positions (which is an array of integers).

snapshotId string

The playlist's snapshot ID against which you want to make the changes

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.removeTracksFromPlaylistInPositions(playlistId, positions, snapshotId, callback)

Remove tracks from a playlist, specifying the positions of the tracks to be removed. See Remove Tracks from a Playlist on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

positions Array.<number>

array of integers containing the positions of the tracks to remove from the playlist.

snapshotId string

The playlist's snapshot ID against which you want to make the changes

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.uploadCustomPlaylistCoverImage(playlistId, imageData, callback)

Upload a custom playlist cover image. See Upload A Custom Playlist Cover Image on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
playlistId string

The id of the playlist. If you know the Spotify URI it is easy to find the playlist id (e.g. spotify:user:xxxx:playlist:<here_is_the_playlist_id>)

imageData string

Base64 encoded JPEG image data, maximum payload size is 256 KB.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getAlbum(albumId, options, callback)

Fetches an album from the Spotify catalog. See Get an Album on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
albumId string

The id of the album. If you know the Spotify URI it is easy to find the album id (e.g. spotify:album:<here_is_the_album_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getAlbumTracks(albumId, options, callback)

Fetches the tracks of an album from the Spotify catalog. See Get an Album's Tracks on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
albumId string

The id of the album. If you know the Spotify URI it is easy to find the album id (e.g. spotify:album:<here_is_the_album_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getAlbums(albumIds, options, callback)

Fetches multiple albums from the Spotify catalog. See Get Several Albums on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
albumIds Array.<string>

The ids of the albums. If you know their Spotify URI it is easy to find their album id (e.g. spotify:album:<here_is_the_album_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getTrack(trackId, options, callback)

Fetches a track from the Spotify catalog. See Get a Track on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
trackId string

The id of the track. If you know the Spotify URI it is easy to find the track id (e.g. spotify:track:<here_is_the_track_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getTracks(trackIds, options, callback)

Fetches multiple tracks from the Spotify catalog. See Get Several Tracks on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
trackIds Array.<string>

The ids of the tracks. If you know their Spotify URI it is easy to find their track id (e.g. spotify:track:<here_is_the_track_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getArtist(artistId, options, callback)

Fetches an artist from the Spotify catalog. See Get an Artist on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
artistId string

The id of the artist. If you know the Spotify URI it is easy to find the artist id (e.g. spotify:artist:<here_is_the_artist_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getArtists(artistIds, options, callback)

Fetches multiple artists from the Spotify catalog. See Get Several Artists on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
artistIds Array.<string>

The ids of the artists. If you know their Spotify URI it is easy to find their artist id (e.g. spotify:artist:<here_is_the_artist_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getArtistAlbums(artistId, options, callback)

Fetches the albums of an artist from the Spotify catalog. See Get an Artist's Albums on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
artistId string

The id of the artist. If you know the Spotify URI it is easy to find the artist id (e.g. spotify:artist:<here_is_the_artist_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getArtistTopTracks(artistId, countryId, options, callback)

Fetches a list of top tracks of an artist from the Spotify catalog, for a specific country. See Get an Artist's Top Tracks on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
artistId string

The id of the artist. If you know the Spotify URI it is easy to find the artist id (e.g. spotify:artist:<here_is_the_artist_id>)

countryId string

The id of the country (e.g. ES for Spain or US for United States)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getArtistRelatedArtists(artistId, options, callback)

Fetches a list of artists related with a given one from the Spotify catalog. See Get an Artist's Related Artists on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
artistId string

The id of the artist. If you know the Spotify URI it is easy to find the artist id (e.g. spotify:artist:<here_is_the_artist_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getFeaturedPlaylists(options, callback)

Fetches a list of Spotify featured playlists (shown, for example, on a Spotify player's "Browse" tab). See Get a List of Featured Playlists on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getNewReleases(options, callback)

Fetches a list of new album releases featured in Spotify (shown, for example, on a Spotify player's "Browse" tab). See Get a List of New Releases on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getCategories(options, callback)

Get a list of categories used to tag items in Spotify (on, for example, the Spotify player's "Browse" tab). See Get a List of Categories on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getCategory(categoryId, options, callback)

Get a single category used to tag items in Spotify (on, for example, the Spotify player's "Browse" tab). See Get a Category on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
categoryId string

The id of the category. These can be found with the getCategories function

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getCategoryPlaylists(categoryId, options, callback)

Get a list of Spotify playlists tagged with a particular category. See Get a Category's Playlists on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
categoryId string

The id of the category. These can be found with the getCategories function

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.search(query, types, options, callback)

Get Spotify catalog information about artists, albums, tracks or playlists that match a keyword string. See Search for an Item on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
query string

The search query

types Array.<string>

An array of item types to search across. Valid types are: 'album', 'artist', 'playlist', and 'track'.

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.searchAlbums(query, options, callback)

Fetches albums from the Spotify catalog according to a query. See Search for an Item on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
query string

The search query

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.searchArtists(query, options, callback)

Fetches artists from the Spotify catalog according to a query. See Search for an Item on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
query string

The search query

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.searchTracks(query, options, callback)

Fetches tracks from the Spotify catalog according to a query. See Search for an Item on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
query string

The search query

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.searchPlaylists(query, options, callback)

Fetches playlists from the Spotify catalog according to a query. See Search for an Item on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
query string

The search query

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.searchShows(query, options, callback)

Fetches shows from the Spotify catalog according to a query. See Search for an Item on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
query string

The search query

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.searchEpisodes(query, options, callback)

Fetches episodes from the Spotify catalog according to a query. See Search for an Item on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
query string

The search query

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getAudioFeaturesForTrack(trackId, callback)

Get audio features for a single track identified by its unique Spotify ID. See Get Audio Features for a Track on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
trackId string

The id of the track. If you know the Spotify URI it is easy to find the track id (e.g. spotify:track:<here_is_the_track_id>)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getAudioFeaturesForTracks(trackIds, callback)

Get audio features for multiple tracks based on their Spotify IDs. See Get Audio Features for Several Tracks on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
trackIds Array.<string>

The ids of the tracks. If you know their Spotify URI it is easy to find their track id (e.g. spotify:track:<here_is_the_track_id>)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getAudioAnalysisForTrack(trackId, callback)

Get audio analysis for a single track identified by its unique Spotify ID. See Get Audio Analysis for a Track on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
trackId string

The id of the track. If you know the Spotify URI it is easy to find the track id (e.g. spotify:track:<here_is_the_track_id>)

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getRecommendations(options, callback)

Create a playlist-style listening experience based on seed artists, tracks and genres. See Get Recommendations Based on Seeds on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getAvailableGenreSeeds(callback)

Retrieve a list of available genres seed parameter values for recommendations. See Available Genre Seeds on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getMyDevices(callback)

Get information about a user’s available devices. See Get a User’s Available Devices on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getMyCurrentPlaybackState(options, callback)

Get information about the user’s current playback state, including track, track progress, and active device. See Get Information About The User’s Current Playback on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getMyCurrentPlayingTrack(options, callback)

Get the object currently being played on the user’s Spotify account. See Get the User’s Currently Playing Track on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.transferMyPlayback(deviceIds, options, callback)

Transfer playback to a new device and determine if it should start playing. See Transfer a User’s Playback on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
deviceIds Array.<string>

A JSON array containing the ID of the device on which playback should be started/transferred.

options Object

A JSON object with options that can be passed.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.play(options, callback)

Play a track on the user's active device See Start/Resume a User's Playback on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.queue(uri, options, callback)

Add an item to the end of the user’s current playback queue. See Add an Item to the User's Playback Queue on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
uri string

The uri of the item to add to the queue. Must be a track or an episode uri.

options Object

A JSON object with options that can be passed.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.pause(options, callback)

Pause playback on the user’s account. See Pause a User’s Playback on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.skipToNext(options, callback)

Skips to next track in the user’s queue. See Skip User’s Playback To Next Track on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.skipToPrevious(options, callback)

Skips to previous track in the user’s queue. Note that this will ALWAYS skip to the previous track, regardless of the current track’s progress. Returning to the start of the current track should be performed using .seek() See Skip User’s Playback To Previous Track on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.seek(position_ms, options, callback)

Seeks to the given position in the user’s currently playing track. See Seek To Position In Currently Playing Track on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
position_ms number

The position in milliseconds to seek to. Must be a positive number.

options Object

A JSON object with options that can be passed.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.setRepeat(state, options, callback)

Set the repeat mode for the user’s playback. Options are repeat-track, repeat-context, and off. See Set Repeat Mode On User’s Playback on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
state String

A string set to 'track', 'context' or 'off'.

options Object

A JSON object with options that can be passed.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.setVolume(volume_percent, options, callback)

Set the volume for the user’s current playback device. See Set Volume For User’s Playback on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
volume_percent number

The volume to set. Must be a value from 0 to 100 inclusive.

options Object

A JSON object with options that can be passed.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.setShuffle(state, options, callback)

Toggle shuffle on or off for user’s playback. See Toggle Shuffle For User’s Playback on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
state bool

Whether or not to shuffle user's playback.

options Object

A JSON object with options that can be passed.

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getShow(showId, options, callback)

Fetches a show from the Spotify catalog. See Get a Show on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
showId string

The id of the show. If you know the Spotify URI it is easy to find the show id (e.g. spotify:show:<here_is_the_show_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getShows(showIds, options, callback)

Fetches multiple shows from the Spotify catalog. See Get Several Shows on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
showIds Array.<string>

The ids of the shows. If you know their Spotify URI it is easy to find their show id (e.g. spotify:show:<here_is_the_show_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getMySavedShows(options, callback)

Fetches current user's saved shows. See Get Current User's Saved Shows on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.addToMySavedShows(showIds, options, callback)

Adds a list of shows to the current user's saved shows. See Save Shows for Current User on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
showIds Array.<string>

The ids of the shows. If you know their Spotify URI it is easy to find their show id (e.g. spotify:show:<here_is_the_show_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.removeFromMySavedShows(showIds, options, callback)

Remove a list of shows from the current user's saved shows. See Remove Shows for Current User on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
showIds Array.<string>

The ids of the shows. If you know their Spotify URI it is easy to find their show id (e.g. spotify:show:<here_is_the_show_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.containsMySavedShows(showIds, options, callback)

Checks if the current user's saved shows contains a certain list of shows. See Check Current User's Saved Shows on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
showIds Array.<string>

The ids of the shows. If you know their Spotify URI it is easy to find their show id (e.g. spotify:show:<here_is_the_show_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getShowEpisodes(showId, options, callback)

Fetches the episodes of a show from the Spotify catalog. See Get a Show's Episodes on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
showId string

The id of the show. If you know the Spotify URI it is easy to find the show id (e.g. spotify:show:<here_is_the_show_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getEpisode(episodeId, options, callback)

Fetches an episode from the Spotify catalog. See Get an Episode on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
episodeId string

The id of the episode. If you know the Spotify URI it is easy to find the episode id (e.g. spotify:episode:<here_is_the_episode_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getEpisodes(episodeIds, options, callback)

Fetches multiple episodes from the Spotify catalog. See Get Several Episodes on the Spotify Developer site for more information about the endpoint.

Parameters

Name Type Description
episodeIds Array.<string>

The ids of the episodes. If you know their Spotify URI it is easy to find their episode id (e.g. spotify:episode:<here_is_the_episode_id>)

options Object

A JSON object with options that can be passed

callback function(Object, Object)

An optional callback that receives 2 parameters. The first one is the error object (null if no error), and the second is the value if the request succeeded.

Returns

Object

Null if a callback is provided, a Promise object otherwise

Constr.getAccessToken()

Gets the access token in use.

Returns

string

accessToken The access token

Constr.setAccessToken(accessToken)

Sets the access token to be used. See the Authorization Guide on the Spotify Developer site for more information about obtaining an access token.

Parameters

Name Type Description
accessToken string

The access token

Returns

Constr.setPromiseImplementation(PromiseImplementation)

Sets an implementation of Promises/A+ to be used. E.g. Q, when. See Conformant Implementations for a list of some available options

Parameters

Name Type Description
PromiseImplementation Object

A Promises/A+ valid implementation

Returns