Back to Top

spotify-web-api-node master

A Node.js wrapper for Spotify's Web API

spotifyApi()

Set the credentials given on Spotify's My Applications page. https://developer.spotify.com/my-applications

Returns

Void

spotifyApi()

Set the credentials given on Spotify's My Applications page. https://developer.spotify.com/my-applications

Returns

Void

spotifyApi()

Set the credentials given on Spotify's My Applications page. https://developer.spotify.com/my-applications

Returns

Void

spotifyApi()

Set the credentials given on Spotify's My Applications page. https://developer.spotify.com/my-applications

Returns

Void

spotifyApi()

This endpoint doesn't require an access token, but it's beneficial to use one as it gives the application a higher rate limit.

Since it's not necessary to get an access token connected to a specific user, this example uses the Client Credentials flow. This flow uses only the client ID and the client secret. https://developer.spotify.com/spotify-web-api/authorization-guide/#client_credentials_flow

Returns

Void

HttpManager.get(The, The)

Make a HTTP GET request.

Parameters

Name Type Description
The BaseRequest

request.

The Function

callback function.

Returns

Void

HttpManager.post(The, The)

Make a HTTP POST request.

Parameters

Name Type Description
The BaseRequest

request.

The Function

callback function.

Returns

Void

HttpManager.del(The, The)

Make a HTTP DELETE request.

Parameters

Name Type Description
The BaseRequest

request.

The Function

callback function.

Returns

Void

HttpManager.put(The, The)

Make a HTTP PUT request.

Parameters

Name Type Description
The BaseRequest

request.

The Function

callback function.

Returns

Void

clientCredentialsGrant(options[, callback])

Request an access token using the Client Credentials flow. Requires that client ID and client secret has been set previous to the call.

Parameters

Name Type Description
options Object

Options.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves into an object containing the access token, token type and time to expiration. If rejected, it contains an error object. Not returned if a callback is given.

authorizationCodeGrant(code[, callback])

Request an access token using the Authorization Code flow. Requires that client ID, client secret, and redirect URI has been set previous to the call.

Parameters

Name Type Description
code string

The authorization code returned in the callback in the Authorization Code flow.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves into an object containing the access token, refresh token, token type and time to expiration. If rejected, it contains an error object. Not returned if a callback is given.

refreshAccessToken([callback])

Refresh the access token given that it hasn't expired. Requires that client ID, client secret and refresh token has been set previous to the call.

Parameters

Name Type Description
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves to an object containing the access token, time to expiration and token type. If rejected, it contains an error object. Not returned if a callback is given.

getTrack(trackId[, options, callback])

Look up a track.

Parameters

Name Type Description
trackId string

The track's ID.

options Object

The possible options, currently only market.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getTrack('3Qm86XLflmIXVm1wcwkgDK').then(...)

Returns

Promise

A promise that if successful, returns an object containing information about the track. Not returned if a callback is given.

getTracks(trackIds[, options, callback])

Look up several tracks.

Parameters

Name Type Description
trackIds Array.<string>

The IDs of the artists.

options Object

The possible options, currently only market.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getArtists(['0oSGxfWSnnOXhD2fKuz2Gy', '3dBVyJ7JuOMt4GE9607Qin']).then(...)

Returns

Promise

A promise that if successful, returns an object containing information about the artists. Not returned if a callback is given.

getAlbum(albumId[, options, callback])

Look up an album.

Parameters

Name Type Description
albumId string

The album's ID.

options Object

The possible options, currently only market.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getAlbum('0sNOF9WDwhWunNAHPD3Baj').then(...)

Returns

Promise

A promise that if successful, returns an object containing information about the album. Not returned if a callback is given.

getAlbums(albumIds[, options, callback])

Look up several albums.

Parameters

Name Type Description
albumIds Array.<string>

The IDs of the albums.

options Object

The possible options, currently only market.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getAlbums(['0oSGxfWSnnOXhD2fKuz2Gy', '3dBVyJ7JuOMt4GE9607Qin']).then(...)

Returns

Promise

A promise that if successful, returns an object containing information about the albums. Not returned if a callback is given.

getArtist(artistId[, callback])

Look up an artist.

Parameters

Name Type Description
artistId string

The artist's ID.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

api.getArtist('1u7kkVrr14iBvrpYnZILJR').then(...)

Returns

Promise

A promise that if successful, returns an object containing information about the artist. Not returned if a callback is given.

getArtists(artistIds[, callback])

Look up several artists.

Parameters

Name Type Description
artistIds Array.<string>

The IDs of the artists.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getArtists(['0oSGxfWSnnOXhD2fKuz2Gy', '3dBVyJ7JuOMt4GE9607Qin']).then(...)

Returns

Promise

A promise that if successful, returns an object containing information about the artists. Not returned if a callback is given.

Search for music entities of certain types.

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

The possible options, e.g. limit, offset.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

search('Abba', ['track', 'playlist'], { limit : 5, offset : 1 }).then(...)

Returns

Promise

A promise that if successful, returns an object containing the search results. The result is paginated. If the promise is rejected, it contains an error object. Not returned if a callback is given.

searchAlbums(query[, options, callback])

Search for an album.

Parameters

Name Type Description
query string

The search query.

options Object

The possible options, e.g. limit, offset.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

searchAlbums('Space Oddity', { limit : 5, offset : 1 }).then(...)

Returns

Promise

A promise that if successful, returns an object containing the search results. The result is paginated. If the promise is rejected, it contains an error object. Not returned if a callback is given.

searchArtists(query[, options, callback])

Search for an artist.

Parameters

Name Type Description
query string

The search query.

options Object

The possible options, e.g. limit, offset.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

searchArtists('David Bowie', { limit : 5, offset : 1 }).then(...)

Returns

Promise

A promise that if successful, returns an object containing the search results. The result is paginated. If the promise is rejected, it contains an error object. Not returned if a callback is given.

searchTracks(query[, options, callback])

Search for a track.

Parameters

Name Type Description
query string

The search query.

options Object

The possible options, e.g. limit, offset.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

searchTracks('Mr. Brightside', { limit : 3, offset : 2 }).then(...)

Returns

Promise

A promise that if successful, returns an object containing the search results. The result is paginated. If the promise is rejected, it contains an error object. Not returned if a callback is given.

searchPlaylists(query, options[, callback])

Search for playlists.

Parameters

Name Type Description
query string

The search query.

options Object

The possible options.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

searchPlaylists('workout', { limit : 1, offset : 0 }).then(...)

Returns

Promise

A promise that if successful, returns an object containing the search results. The result is paginated. If the promise is rejected, it contains an error object. Not returned if a callback is given.

getArtistAlbums(artistId[, callback])

Get an artist's albums.

Parameters

Name Type Description
artistId string

The artist's ID.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getArtistAlbums('0oSGxfWSnnOXhD2fKuz2Gy', { album_type : 'album', country : 'GB', limit : 2, offset : 5 }).then(...)

Returns

Promise

A promise that if successful, returns an object containing the albums for the given artist. The result is paginated. If the promise is rejected, it contains an error object. Not returned if a callback is given.

getAlbumTracks(albumId[, callback])

Get the tracks of an album.

Parameters

Name Type Description
albumId

the album's ID.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getAlbumTracks('41MnTivkwTO3UUJ8DrqEJJ', { limit : 5, offset : 1 }).then(...)

Returns

Promise

A promise that if successful, returns an object containing the tracks in the album. The result is paginated. If the promise is rejected. it contains an error object. Not returned if a callback is given.

getArtistTopTracks(artistId, country[, callback])

Get an artist's top tracks.

Parameters

Name Type Description
artistId string

The artist's ID.

country string

The country/territory where the tracks are most popular. (format: ISO 3166-1 alpha-2)

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getArtistTopTracks('0oSGxfWSnnOXhD2fKuz2Gy', 'GB').then(...)

Returns

Promise

A promise that if successful, returns an object containing the artist's top tracks in the given country. If the promise is rejected, it contains an error object. Not returned if a callback is given.

getArtistRelatedArtists(artistId[, callback])

Get related artists.

Parameters

Name Type Description
artistId string

The artist's ID.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getArtistRelatedArtists('0oSGxfWSnnOXhD2fKuz2Gy').then(...)

Returns

Promise

A promise that if successful, returns an object containing the related artists. If the promise is rejected, it contains an error object. Not returned if a callback is given.

getUser(userId[, callback])

Get information about a user.

Parameters

Name Type Description
userId

The user ID.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getUser('thelinmichael').then(...)

Returns

Promise

A promise that if successful, resolves to an object containing information about the user. If the promise is rejected, it contains an error object. Not returned if a callback is given.

getMe([callback])

Get information about the user that has signed in (the current user).

Parameters

Name Type Description
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getMe().then(...)

Returns

Promise

A promise that if successful, resolves to an object containing information about the user. The amount of information depends on the permissions given by the user. If the promise is rejected, it contains an error object. Not returned if a callback is given.

getUserPlaylists(userId[, options, callback])

Get a user's playlists.

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

The options supplied to this request.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getUserPlaylists('thelinmichael').then(...)

Returns

Promise

A promise that if successful, resolves to an object containing a list of playlists. If rejected, it contains an error object. Not returned if a callback is given.

getPlaylist(userId, playlistId[, options, callback])

Get a playlist.

Parameters

Name Type Description
userId string

The playlist's owner's user ID.

playlistId string

The playlist's ID.

options Object

The options supplied to this request.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getPlaylist('thelinmichael', '3EsfV6XzCHU8SPNdbnFogK').then(...)

Returns

Promise

A promise that if successful, resolves to an object containing the playlist. If rejected, it contains an error object. Not returned if a callback is given.

getPlaylistTracks(userId, playlistId[, options, callback])

Get tracks in a playlist.

Parameters

Name Type Description
userId string

THe playlist's owner's user ID.

playlistId string

The playlist's ID.

options Object

Optional options, such as fields.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getPlaylistTracks('thelinmichael', '3ktAYNcRHpazJ9qecm3ptn').then(...)

Returns

Promise

A promise that if successful, resolves to an object that containing the tracks in the playlist. If rejected, it contains an error object. Not returned if a callback is given.

createPlaylist(userId, playlistName[, options, callback])

Create a playlist.

Parameters

Name Type Description
userId string

The playlist's owner's user ID.

playlistName string

The name of the playlist.

options Object

The possible options, currently only public.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

createPlaylist('thelinmichael', 'My cool playlist!', { public : false }).then(...)

Returns

Promise

A promise that if successful, resolves to an object containing information about the created playlist. If rejected, it contains an error object. Not returned if a callback is given.

followPlaylist(userId, playlistId[, options, callback])

Follow a playlist.

Parameters

Name Type Description
userId string

The playlist's owner's user ID

playlistId string

The playlist's ID

options Object

The possible options, currently only public.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, simply resolves to an empty object. If rejected, it contains an error object. Not returned if a callback is given.

unfollowPlaylist(userId, playlistId[, options, callback])

Unfollow a playlist.

Parameters

Name Type Description
userId string

The playlist's owner's user ID

playlistId string

The playlist's ID

options Object

The possible options, currently only public.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, simply resolves to an empty object. If rejected, it contains an error object. Not returned if a callback is given.

changePlaylistDetails(userId, playlistId[, options, callback])

Change playlist details.

Parameters

Name Type Description
userId string

The playlist's owner's user ID

playlistId string

The playlist's ID

options Object

The possible options, e.g. name, public.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

changePlaylistDetails('thelinmichael', '3EsfV6XzCHU8SPNdbnFogK', {name: 'New name', public: true}).then(...)

Returns

Promise

A promise that if successful, simply resolves to an empty object. If rejected, it contains an error object. Not returned if a callback is given.

uploadCustomPlaylistCoverImage(userId, playlistId, base64URI[, callback])

Replace the image used to represent a specific playlist.

Parameters

Name Type Description
userId string

The playlist's owner's user ID

playlistId string

The playlist's ID

base64URI string

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

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

uploadCustomPlaylistCoverImage('thelinmichael', '3EsfV6XzCHU8SPNdbnFogK', 'longbase64uri').then(...)

Returns

Promise

A promise that if successful, simply resolves to an empty object. If rejected, it contains an error object. Not returned if a callback is given.

addTracksToPlaylist(userId, playlistId, tracks[, options, callback])

Add tracks to a playlist.

Parameters

Name Type Description
userId string

The playlist's owner's user ID

playlistId string

The playlist's ID

tracks Array.<string>

URIs of the tracks to add to the playlist.

options Object

Options, position being the only one.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

addTracksToPlaylist('thelinmichael', '3EsfV6XzCHU8SPNdbnFogK',               '["spotify:track:4iV5W9uYEdYUVa79Axb7Rh", "spotify:track:1301WleyT98MSxVHPZCA6M"]').then(...)

Returns

Promise

A promise that if successful returns an object containing a snapshot_id. If rejected, it contains an error object. Not returned if a callback is given.

removeTracksFromPlaylist(userId, playlistId, tracks, options[, callback])

Remove tracks from a playlist.

Parameters

Name Type Description
userId string

The playlist's owner's user ID

playlistId string

The playlist's ID

tracks Array.<Object>

An array of objects containing a property called uri with the track URI (String), and a an optional property called positions (int[]), e.g. { uri : "spotify:track:491rM2JN8KvmV6p0oDDuJT", positions : [0, 15] }

options Object

Options, snapshot_id being the only one.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful returns an object containing a snapshot_id. If rejected, it contains an error object. Not returned if a callback is given.

removeTracksFromPlaylistByPosition(userId, playlistId, positions, snapshot_id[, callback])

Remove tracks from a playlist by position instead of specifying the tracks' URIs.

Parameters

Name Type Description
userId string

The playlist's owner's user ID

playlistId string

The playlist's ID

positions Array.<int>

The positions of the tracks in the playlist that should be removed

snapshot_id string

The snapshot ID, or version, of the playlist. Required

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful returns an object containing a snapshot_id. If rejected, it contains an error object. Not returned if a callback is given.

replaceTracksInPlaylist(userId, playlistId, uris[, callback])

Replace tracks in a playlist.

Parameters

Name Type Description
userId string

The playlist's owner's user ID

playlistId string

The playlist's ID

uris Array.<Object>

An array of track URIs (strings)

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful returns an empty object. If rejected, it contains an error object. Not returned if a callback is given.

reorderTracksInPlaylist(userId, playlistId, rangeStart, insertBefore, options[, callback])

Reorder tracks in a playlist.

Parameters

Name Type Description
userId string

The playlist's owner's user ID

playlistId string

The playlist's ID

rangeStart int

The position of the first track to be reordered.

insertBefore int

The position where the tracks should be inserted.

options Object

Optional parameters, i.e. range_length and snapshot_id.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful returns an object containing a snapshot_id. If rejected, it contains an error object. Not returned if a callback is given.

getAudioFeaturesForTrack(trackId[, callback])

Get audio features for a single track identified by its unique Spotify ID.

Parameters

Name Type Description
trackId string

The track ID

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getAudioFeaturesForTrack('38P3Q4QcdjQALGF2Z92BmR').then(...)

Returns

Promise

A promise that if successful, resolves to an object containing information about the audio features. If the promise is rejected, it contains an error object. Not returned if a callback is given.

getAudioAnalysisForTrack(trackId[, callback])

Get audio analysis for a single track identified by its unique Spotify ID.

Parameters

Name Type Description
trackId string

The track ID

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getAudioAnalysisForTrack('38P3Q4QcdjQALGF2Z92BmR').then(...)

Returns

Promise

A promise that if successful, resolves to an object containing information about the audio analysis. If the promise is rejected, it contains an error object. Not returned if a callback is given.

getAudioFeaturesForTracks(trackIds[, callback])

Get audio features for multiple tracks identified by their unique Spotify ID.

Parameters

Name Type Description
trackIds Array.<string>

The track IDs

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getAudioFeaturesForTracks(['38P3Q4QcdjQALGF2Z92BmR', '2HO2bnoMrpnZUbUqiilLHi']).then(...)

Returns

Promise

A promise that if successful, resolves to an object containing information about the audio features for the tracks. If the promise is rejected, it contains an error object. Not returned if a callback is given.

getRecommendations([options, callback])

Create a playlist-style listening experience based on seed artists, tracks and genres.

Parameters

Name Type Description
options Object

The options supplied to this request.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getRecommendations({ min_energy: 0.4, seed_artists: ['6mfK6Q2tzLMEchAr0e9Uzu', '4DYFVNKZ1uixa6SQTvzQwJ'], min_popularity: 50 }).then(...)

Returns

Promise

A promise that if successful, resolves to an object containing a list of tracks and a list of seeds. If rejected, it contains an error object. Not returned if a callback is given.

getAvailableGenreSeeds([callback])

Retrieve a list of available genres seed parameter values for recommendations.

Parameters

Name Type Description
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

getAvailableGenreSeeds().then(...)

Returns

Promise

A promise that if successful, resolves to an object containing a list of available genres to be used as seeds for recommendations. If rejected, it contains an error object. Not returned if a callback is given.

createAuthorizeURL(scopes, state, showDialog)

Retrieve a URL where the user can give the application permissions.

Parameters

Name Type Description
scopes Array.<string>

The scopes corresponding to the permissions the application needs.

state string

A parameter that you can use to maintain a value between the request and the callback to redirect_uri.It is useful to prevent CSRF exploits.

showDialog boolean

A parameter that you can use to force the user to approve the app on each login rather than being automatically redirected.

Returns

string

The URL where the user can give application permissions.

getMySavedTracks([options, callback])

Retrieve the tracks that are saved to the authenticated users Your Music library.

Parameters

Name Type Description
options Object

Options, being market, limit, and/or offset.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

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

containsMySavedTracks(trackIds[, callback])

Check if one or more tracks is already saved in the current Spotify user’s “Your Music” library.

Parameters

Name Type Description
trackIds Array.<string>

The track IDs

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves into an array of booleans. The order of the returned array's elements correspond to the track ID in the request. The boolean value of true indicates that the track is part of the user's library, otherwise false. Not returned if a callback is given.

removeFromMySavedTracks(trackIds[, callback])

Remove a track from the authenticated user's Your Music library.

Parameters

Name Type Description
trackIds Array.<string>

The track IDs

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful returns null, otherwise an error. Not returned if a callback is given.

addToMySavedTracks(trackIds[, callback])

Add a track from the authenticated user's Your Music library.

Parameters

Name Type Description
trackIds Array.<string>

The track IDs

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful returns null, otherwise an error. Not returned if a callback is given.

removeFromMySavedAlbums(albumIds[, callback])

Remove an album from the authenticated user's Your Music library.

Parameters

Name Type Description
albumIds Array.<string>

The album IDs

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful returns null, otherwise an error. Not returned if a callback is given.

addToMySavedAlbums(albumIds[, callback])

Add an album from the authenticated user's Your Music library.

Parameters

Name Type Description
albumIds Array.<string>

The track IDs

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful returns null, otherwise an error. Not returned if a callback is given.

getMySavedAlbums([options, callback])

Retrieve the albums that are saved to the authenticated users Your Music library.

Parameters

Name Type Description
options Object

Options, being market, limit, and/or offset.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

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

containsMySavedAlbums(albumIds[, callback])

Check if one or more albums is already saved in the current Spotify user’s “Your Music” library.

Parameters

Name Type Description
albumIds Array.<string>

The album IDs

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves into an array of booleans. The order of the returned array's elements correspond to the album ID in the request. The boolean value of true indicates that the album is part of the user's library, otherwise false. Not returned if a callback is given.

getMyTopArtists([options, callback])

Get the current user's top artists based on calculated affinity.

Parameters

Name Type Description
options Object

Options, being time_range, limit, offset.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves into a paging object of artists, otherwise an error. Not returned if a callback is given.

getMyTopTracks([options, callback])

Get the current user's top tracks based on calculated affinity.

Parameters

Name Type Description
options Object

Options, being time_range, limit, offset.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves into a paging object of tracks, otherwise an error. Not returned if a callback is given.

getMyRecentlyPlayedTracks([options, callback])

Get the Current User's Recently Played Tracks

Parameters

Name Type Description
options Object

Options, being type, after, limit, before.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves into a paging object of tracks, otherwise an error. Not returned if a callback is given.

getMyDevices([callback])

Get the Current User's Connect Devices

Parameters

Name Type Description
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves into a paging object of tracks, otherwise an error. Not returned if a callback is given.

getMyCurrentPlayingTrack([options, callback])

Get the Current User's Currently Playing Track.

Parameters

Name Type Description
options Object

Options, being market.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves into a paging object of tracks, otherwise an error. Not returned if a callback is given.

getMyCurrentPlaybackState([options, callback])

Get the Current User's Current Playback State

Parameters

Name Type Description
options Object

Options, being market.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves into a paging object of tracks, otherwise an error. Not returned if a callback is given.

transferMyPlayback([options, callback])

Transfer a User's Playback

Parameters

Name Type Description
options Object

Options, being market.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves into a paging object of tracks, otherwise an error. Not returned if a callback is given.

play([options, callback])

Starts o Resumes the Current User's Playback

Parameters

Name Type Description
options Object

Options, being device_id, context_uri, offset, uris.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

playbackResume({context_uri: 'spotify:album:5ht7ItJgpBH7W6vJ5BqpPr'}).then(...)

Returns

Promise

A promise that if successful, resolves into a paging object of tracks, otherwise an error. Not returned if a callback is given.

pause([options, callback])

Pauses the Current User's Playback

Parameters

Name Type Description
options Object

Options, for now device_id,

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

playbackPause().then(...)

Returns

Promise

A promise that if successful, resolves into a paging object of tracks, otherwise an error. Not returned if a callback is given.

skipToPrevious([callback])

Skip the Current User's Playback To Previous Track

Parameters

Name Type Description
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

playbackPrevious().then(...)

Returns

Promise

A promise that if successful, resolves into a paging object of tracks, otherwise an error. Not returned if a callback is given.

skipToNext([callback])

Skip the Current User's Playback To Next Track

Parameters

Name Type Description
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

playbackNext().then(...)

Returns

Promise

A promise that if successful, resolves into a paging object of tracks, otherwise an error. Not returned if a callback is given.

setRepeat([options, callback])

Set Repeat Mode On The Current User's Playback

Parameters

Name Type Description
options Object

Options, being state (track, context, off).

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

playbackRepeat({state: 'context'}).then(...)

Returns

Promise

A promise that if successful, resolves into a paging object of tracks, otherwise an error. Not returned if a callback is given.

setShuffle([options, callback])

Set Shuffle Mode On The Current User's Playback

Parameters

Name Type Description
options Object

Options, being state (true, false).

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

playbackShuffle({state: 'false'}).then(...)

Returns

Promise

A promise that if successful, resolves into a paging object of tracks, otherwise an error. Not returned if a callback is given.

followUsers(userIds[, callback])

Add the current user as a follower of one or more other Spotify users.

Parameters

Name Type Description
userIds Array.<string>

The IDs of the users to be followed.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

followUsers(['thelinmichael', 'wizzler']).then(...)

Returns

Promise

A promise that if successful, simply resolves to an empty object. If rejected, it contains an error object. Not returned if a callback is given.

followArtists(artistIds[, callback])

Add the current user as a follower of one or more artists.

Parameters

Name Type Description
artistIds Array.<string>

The IDs of the artists to be followed.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

followArtists(['0LcJLqbBmaGUft1e9Mm8HV', '3gqv1kgivAc92KnUm4elKv']).then(...)

Returns

Promise

A promise that if successful, simply resolves to an empty object. If rejected, it contains an error object. Not returned if a callback is given.

unfollowUsers(userIds[, callback])

Remove the current user as a follower of one or more other Spotify users.

Parameters

Name Type Description
userIds Array.<string>

The IDs of the users to be unfollowed.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

unfollowUsers(['thelinmichael', 'wizzler']).then(...)

Returns

Promise

A promise that if successful, simply resolves to an empty object. If rejected, it contains an error object. Not returned if a callback is given.

unfollowArtists(artistIds[, callback])

Remove the current user as a follower of one or more artists.

Parameters

Name Type Description
artistIds Array.<string>

The IDs of the artists to be unfollowed.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

unfollowArtists(['0LcJLqbBmaGUft1e9Mm8HV', '3gqv1kgivAc92KnUm4elKv']).then(...)

Returns

Promise

A promise that if successful, simply resolves to an empty object. If rejected, it contains an error object. Not returned if a callback is given.

isFollowingUsers(userIds[, callback])

Check to see if the current user is following one or more other Spotify users.

Parameters

Name Type Description
userIds Array.<string>

The IDs of the users to check if are followed by the current user.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

isFollowingUsers(['thelinmichael', 'wizzler']).then(...)

Returns

Promise

A promise that if successful, resolves into an array of booleans. The order of the returned array's elements correspond to the users IDs in the request. The boolean value of true indicates that the user is following that user, otherwise is not. Not returned if a callback is given.

getFollowedArtists([options, callback])

Get the current user's followed artists.

Parameters

Name Type Description
options Object

Options, being after and limit.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

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

areFollowingPlaylist(userId, playlistId, User[, callback])

Check if users are following a playlist.

Parameters

Name Type Description
userId string

The playlist's owner's user ID

playlistId string

The playlist's ID

User Array.<String>

IDs of the following users

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful returns an array of booleans. If rejected, it contains an error object. Not returned if a callback is given.

isFollowingArtists(artistIds[, callback])

Check to see if the current user is following one or more artists.

Parameters

Name Type Description
artistIds Array.<string>

The IDs of the artists to check if are followed by the current user.

callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Examples

isFollowingArtists(['0LcJLqbBmaGUft1e9Mm8HV', '3gqv1kgivAc92KnUm4elKv']).then(...)

Returns

Promise

A promise that if successful, resolves into an array of booleans. The order of the returned array's elements correspond to the artists IDs in the request. The boolean value of true indicates that the user is following that artist, otherwise is not. Not returned if a callback is given.

getNewReleases([options, callback])

Retrieve new releases

Parameters

Name Type Description
options Object

Options, being country, limit and/or offset.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

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

getFeaturedPlaylists([options, callback])

Retrieve featured playlists

Parameters

Name Type Description
options Object

Options, being country, locale, timestamp, limit, offset.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

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

getCategories([options, callback])

Retrieve a list of categories used to tag items in Spotify (e.g. in the 'Browse' tab)

Parameters

Name Type Description
options Object

Options, being country, locale, limit, offset.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves to an object containing a paging object of categories. Not returned if a callback is given.

getCategory(categoryId[, options, callback])

Retrieve a category.

Parameters

Name Type Description
categoryId string

The id of the category to retrieve.

options Object

Options, being country, locale.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves to an object containing a category object. Not returned if a callback is given.

getPlaylistsForCategory(categoryId[, options, callback])

Retrieve playlists for a category.

Parameters

Name Type Description
categoryId string

The id of the category to retrieve playlists for.

options Object

Options, being country, limit, offset.

Optional
callback requestCallback

Optional callback method to be called instead of the promise.

Optional

Returns

Promise

A promise that if successful, resolves to a paging object containing simple playlists. Not returned if a callback is given.