Reference · Tools

Spotify

Access and control Spotify music data: albums, artists, playlists, tracks, library, and player

Action Utility v1

The Spotify node reads and manages music data — albums, artists, tracks and playlists — handles your library, and controls playback. A typical build is appending newly released tracks from followed artists into a weekly playlist automatically.

Node type
Action
Parameters
31
Outputs
Output, Error
Credentials
Spotify OAuth2

Spotify

Access and control Spotify music data

Overview

Spotify is a music streaming platform. This tool provides access to the Spotify Web API for searching and retrieving albums, artists, tracks, and playlists; managing user playlists (create, add/remove tracks); accessing user library (liked tracks, followed artists); and controlling playback (play, pause, skip, volume, queue). All operations use OAuth2 authentication via the Spotify API.

Category: Utility
Tool Name: spotify
Version: 1

Appearance: Icon: si-spotify | Color: #1DB954

Node Type

Action — processes input items and produces output

Input / Output

DirectionPort(s)
InputInput
OutputOutput, Error

Credentials

This tool requires Spotify OAuth2 credentials. See the Credentials Guide for setup instructions.

Resources

ResourceValue
Albumalbum
Artistartist
Librarylibrary
My DatamyData
Playerplayer
Playlistplaylist
Tracktrack

Operations

OperationValueDescription
Add Song to QueueaddSongToQueueAdd a song to your queue
Currently PlayingcurrentlyPlayingGet your currently playing track
Next SongnextSongSkip to your next track
PausepausePause your music
Previous SongpreviousSongSkip to your previous song
Recently PlayedrecentlyPlayedGet your recently played tracks
ResumeresumeResume playback on the current active device
Set VolumevolumeSet volume on the current active device
Start MusicstartMusicStart playing a playlist, artist, or album
GetgetGet an album, artist, playlist or track by URI or ID
Get New ReleasesgetNewReleasesGet a list of new album releases
Get TracksgetTracksGet an album’s or a playlist’s tracks by URI or ID
SearchsearchSearch albums, artists, playlists or tracks by keyword
Get AlbumsgetAlbumsGet an artist’s albums by URI or ID
Get Related ArtistsgetRelatedArtistsGet an artist’s related artists by URI or ID
Get Top TracksgetTopTracksGet an artist’s top tracks by URI or ID
Add an ItemaddAdd tracks to a playlist by track and playlist URI or ID
Create a PlaylistcreateCreate a new playlist
Get the User’s PlaylistsgetUserPlaylistsGet a user’s playlists
Remove an ItemdeleteRemove tracks from a playlist by track and playlist URI or ID
Get Audio FeaturesgetAudioFeaturesGet audio features for a track by URI or ID
Get Liked TracksgetLikedTracksGet the user’s liked tracks
Get Following ArtistsgetFollowingArtistsGet your followed artists

Which operations you see depends on the resource: playeraddSongToQueue, currentlyPlaying, nextSong, pause, previousSong, recentlyPlayed, resume, volume, startMusic; albumget, getNewReleases, getTracks, search; artistget, getAlbums, getRelatedArtists, getTopTracks, search; playlistadd, create, get, getUserPlaylists, getTracks, delete, search; trackget, getAudioFeatures, search; librarygetLikedTracks; myDatagetFollowingArtists.

Parameters

Currently Playing, Next Song, Pause, Previous Song and Resume take no parameters of their own — see All Operations.

Wherever an ID is asked for you can paste either a Spotify URI (spotify:track:0xE4LEFzSNGsz1F6kvXsHU) or the bare ID.

Player: Start Music

ParameterTypeRequiredDefaultDescription
Resource ID (id)stringYesEnter a playlist, artist, or album URI or ID.

Player: Add Song to Queue

ParameterTypeRequiredDefaultDescription
Track ID (id)stringYesEnter a track URI or ID.

Player: Set Volume

ParameterTypeRequiredDefaultDescription
VolumenumberYes50The volume percentage to set. Between 0 and 100.

Player: Recently Played

ParameterTypeRequiredDefaultDescription
Return AllbooleanNofalseWhether to return all results or only up to a given limit.
LimitnumberNo50Max number of results to return. Between 1 and 50. (shown when Return All is false)

Album: Get

ParameterTypeRequiredDefaultDescription
Album ID (id)stringYesThe album’s Spotify URI or ID.

Album: Get Tracks

ParameterTypeRequiredDefaultDescription
Album ID (id)stringYesThe album’s Spotify URI or ID.
Return AllbooleanNofalseWhether to return all results or only up to a given limit.
LimitnumberNo50Max number of results to return. Between 1 and 100. (shown when Return All is false)

Album: Get New Releases

ParameterTypeRequiredDefaultDescription
Return AllbooleanNofalseWhether to return all results or only up to a given limit.
LimitnumberNo50Max number of results to return. Between 1 and 100. (shown when Return All is false)
FilterscollectionNo{}Narrow which new releases are returned.
— Country (country)stringNoUSISO 3166-1 alpha-2 country code to filter new releases by (e.g. US, GB, DE).
ParameterTypeRequiredDefaultDescription
Search Keyword (query)stringYesThe keyword term to search for.
Return AllbooleanNofalseWhether to return all results or only up to a given limit.
LimitnumberNo50Max number of results to return. Between 1 and 100. (shown when Return All is false)
FilterscollectionNo{}Narrow the search.
— Country (market)stringNoISO 3166-1 alpha-2 country code. If specified, only content playable in that market is returned.

Artist: Get

ParameterTypeRequiredDefaultDescription
Artist ID (id)stringYesThe artist’s Spotify URI or ID. (hidden when Operation is search)

Artist: Get Albums

ParameterTypeRequiredDefaultDescription
Artist ID (id)stringYesThe artist’s Spotify URI or ID. (hidden when Operation is search)
Return AllbooleanNofalseWhether to return all results or only up to a given limit.
LimitnumberNo50Max number of results to return. Between 1 and 100. (shown when Return All is false)
ParameterTypeRequiredDefaultDescription
Artist ID (id)stringYesThe artist’s Spotify URI or ID. (hidden when Operation is search)

Artist: Get Top Tracks

ParameterTypeRequiredDefaultDescription
Artist ID (id)stringYesThe artist’s Spotify URI or ID. (hidden when Operation is search)
CountrystringYesUSTop tracks in which country? Enter the ISO 3166-1 alpha-2 country code (e.g. US, GB, DE).
ParameterTypeRequiredDefaultDescription
Search Keyword (query)stringYesThe keyword term to search for.
Return AllbooleanNofalseWhether to return all results or only up to a given limit.
LimitnumberNo50Max number of results to return. Between 1 and 100. (shown when Return All is false)
FilterscollectionNo{}Narrow the search.
— Country (market)stringNoISO 3166-1 alpha-2 country code. If specified, only content playable in that market is returned.

Playlist: Create a Playlist

ParameterTypeRequiredDefaultDescription
NamestringYesName of the playlist to create.
Additional FieldscollectionNo{}Optional playlist settings.
— DescriptionstringNoDescription for the playlist to create.
— PublicbooleanNotrueWhether the playlist is publicly accessible.

Playlist: Add an Item

ParameterTypeRequiredDefaultDescription
Playlist ID (id)stringYesThe playlist’s Spotify URI or its ID.
Track ID (trackID)stringYesThe track’s Spotify URI or its ID. The track to add/delete from the playlist.
Additional FieldscollectionNo{}Optional placement settings.
— PositionnumberNo0The new track’s position in the playlist.

Playlist: Remove an Item

ParameterTypeRequiredDefaultDescription
Playlist ID (id)stringYesThe playlist’s Spotify URI or its ID.
Track ID (trackID)stringYesThe track’s Spotify URI or its ID. The track to add/delete from the playlist.

Playlist: Get

ParameterTypeRequiredDefaultDescription
Playlist ID (id)stringYesThe playlist’s Spotify URI or its ID.

Playlist: Get Tracks

ParameterTypeRequiredDefaultDescription
Playlist ID (id)stringYesThe playlist’s Spotify URI or its ID.
Return AllbooleanNofalseWhether to return all results or only up to a given limit.
LimitnumberNo50Max number of results to return. Between 1 and 100. (shown when Return All is false)

Playlist: Get the User’s Playlists

ParameterTypeRequiredDefaultDescription
Return AllbooleanNofalseWhether to return all results or only up to a given limit.
LimitnumberNo50Max number of results to return. Between 1 and 100. (shown when Return All is false)
ParameterTypeRequiredDefaultDescription
Search Keyword (query)stringYesThe keyword term to search for.
Return AllbooleanNofalseWhether to return all results or only up to a given limit.
LimitnumberNo50Max number of results to return. Between 1 and 100. (shown when Return All is false)
FilterscollectionNo{}Narrow the search.
— Country (market)stringNoISO 3166-1 alpha-2 country code. If specified, only content playable in that market is returned.

Track: Get

ParameterTypeRequiredDefaultDescription
Track ID (id)stringYesThe track’s Spotify URI or ID. (hidden when Operation is search)

Track: Get Audio Features

ParameterTypeRequiredDefaultDescription
Track ID (id)stringYesThe track’s Spotify URI or ID. (hidden when Operation is search)
ParameterTypeRequiredDefaultDescription
Search Keyword (query)stringYesThe keyword term to search for.
Return AllbooleanNofalseWhether to return all results or only up to a given limit.
LimitnumberNo50Max number of results to return. Between 1 and 100. (shown when Return All is false)
FilterscollectionNo{}Narrow the search.
— Country (market)stringNoISO 3166-1 alpha-2 country code. If specified, only content playable in that market is returned.

Library: Get Liked Tracks

ParameterTypeRequiredDefaultDescription
Return AllbooleanNofalseWhether to return all results or only up to a given limit.
LimitnumberNo50Max number of results to return. Between 1 and 100. (shown when Return All is false)

My Data: Get Following Artists

ParameterTypeRequiredDefaultDescription
Return AllbooleanNofalseWhether to return all results or only up to a given limit.
LimitnumberNo50Max number of results to return. Between 1 and 50. (shown when Return All is false)

All Operations

ParameterTypeRequiredDefaultDescription
Spotify AccountcredentialNoConnect your Spotify account via OAuth2. Pick the connected account this node should use.
Max ConcurrencynumberNo10Maximum number of items to process concurrently.

Output Data

Whatever Spotify returns is merged onto the input item JSON — the incoming fields pass through unchanged, and binary data is forwarded.

Operations that return a list fan out — one output item per record, each merged onto the input item:

Resource / OperationOne item per
player / recentlyPlayedRecently played entry
album / getNewReleasesNew-release album
album / getTracksTrack on the album
album / searchMatching album
artist / getAlbumsAlbum by the artist
artist / getRelatedArtistsRelated artist
artist / getTopTracksTop track
artist / searchMatching artist
playlist / getTracksTrack in the playlist
playlist / getUserPlaylistsPlaylist
playlist / searchMatching playlist
track / searchMatching track
library / getLikedTracksLiked track
myData / getFollowingArtistsFollowed artist

With Return All off, only up to Limit records are requested. If the list is empty, the input item produces no output item at all.

Operations that produce exactly one output item:

Resource / OperationFields merged onto the item
player / currentlyPlayingThe current playback state.
album / get, artist / get, playlist / get, track / getThe full object for that album, artist, playlist or track.
track / getAudioFeaturesThe track’s audio-feature values.
playlist / createThe created playlist.
playlist / addSpotify’s add response.
player / addSongToQueue, nextSong, pause, previousSong, resume, volume, startMusic, and playlist / deletesuccess: true — these commands return no content of their own.

Reference the result downstream by expression, e.g. {{ $json.name }} or {{ $json.id }}.

Usage Examples

  • Search for tracks by keyword
  • Get album details by Spotify URI
  • Create a new playlist
  • Add a track to a playlist
  • Get currently playing track
  • Skip to next song
  • Set player volume
  • Get user liked tracks
  • Get artist top tracks by country
  • Search for playlists

Example Configuration

Search tracks by a keyword from the incoming item, limited to a market:

{
  "type": "spotify",
  "parameters": {
    "resource": "track",
    "operation": "search",
    "query": "{{ $json.searchTerm }}",
    "returnAll": false,
    "limit": 20,
    "filters": {
      "market": "US"
    }
  }
}

Fetch an album by URI:

{
  "type": "spotify",
  "parameters": {
    "resource": "album",
    "operation": "get",
    "id": "spotify:album:1YZ3k65Mqw3G8FzYlW1mmp"
  }
}

Get an artist’s top tracks in Germany:

{
  "type": "spotify",
  "parameters": {
    "resource": "artist",
    "operation": "getTopTracks",
    "id": "spotify:artist:4LLpKhyESsyAXpc4laK94U",
    "country": "DE"
  }
}

Create a private playlist:

{
  "type": "spotify",
  "parameters": {
    "resource": "playlist",
    "operation": "create",
    "name": "Favorite Songs",
    "additionalFields": {
      "description": "These are all my favorite songs.",
      "public": false
    }
  }
}

Add a track from the incoming item to the top of a playlist:

{
  "type": "spotify",
  "parameters": {
    "resource": "playlist",
    "operation": "add",
    "id": "spotify:playlist:37i9dQZF1DWUhI3iC1khPH",
    "trackID": "{{ $json.trackUri }}",
    "additionalFields": {
      "position": 0
    }
  }
}

Remove a track from a playlist:

{
  "type": "spotify",
  "parameters": {
    "resource": "playlist",
    "operation": "delete",
    "id": "spotify:playlist:37i9dQZF1DWUhI3iC1khPH",
    "trackID": "spotify:track:0xE4LEFzSNGsz1F6kvXsHU"
  }
}

List every liked track in the library — one item each:

{
  "type": "spotify",
  "parameters": {
    "resource": "library",
    "operation": "getLikedTracks",
    "returnAll": true
  }
}

Queue a track and then start playback of an album:

{
  "type": "spotify",
  "parameters": {
    "resource": "player",
    "operation": "addSongToQueue",
    "id": "spotify:track:0xE4LEFzSNGsz1F6kvXsHU"
  }
}
{
  "type": "spotify",
  "parameters": {
    "resource": "player",
    "operation": "startMusic",
    "id": "spotify:album:1YZ3k65Mqw3G8FzYlW1mmp"
  }
}

Set the volume on the active device:

{
  "type": "spotify",
  "parameters": {
    "resource": "player",
    "operation": "volume",
    "volumePercent": 30
  }
}

Browse new releases for a country:

{
  "type": "spotify",
  "parameters": {
    "resource": "album",
    "operation": "getNewReleases",
    "returnAll": false,
    "limit": 20,
    "filters": {
      "country": "GB"
    }
  }
}

Error Handling

ModeBehavior
stopHalts workflow on first error
continueSkips failed items, passes successful ones through
errorPortRoutes failed items to Error output port

Tips

Access and control Spotify music data — search and retrieve albums, artists, tracks and playlists, manage your playlists and library, and control playback.

Behavior notes

  • Player operations need an active device. Spotify only accepts play, pause, skip, volume and queue commands when something is already playing or a device is active on the account; otherwise the API rejects the call.
  • URIs and bare IDs both work. spotify:track:0xE4LEFzSNGsz1F6kvXsHU and 0xE4LEFzSNGsz1F6kvXsHU are interchangeable in every ID field.
  • Two different Track ID fields exist. On the player it is written as id; on a playlist add or remove it is trackID. Getting them the wrong way round in hand-written configuration is the most common mistake with this node.
  • Return All pages through everything. On a large library or a long playlist that means many API calls; leave it off and set a Limit when you only need a sample.
  • Country filters differ by operation. New releases take a plain country code, while the search filters take a market code — both are ISO 3166-1 alpha-2.
  • Scopes matter. Library, My Data, playlist modification and every player command require the matching Spotify scopes on the connected account; a 403 from Spotify almost always means a missing scope rather than a bad ID.

Frequently asked questions

Why are my playback commands rejected?

Player operations need an active device. Spotify only accepts play, pause, skip, volume and queue commands when something is already playing or a device is active on the account.

Do I need full Spotify URIs?

No — URIs and bare IDs both work, so you can pass whichever form an upstream node produced.

What can it manage besides playback?

Searching and retrieving albums, artists, tracks and playlists, plus managing your own playlists and library.

Which credential does it need?

A Spotify OAuth2 credential for the account whose library and playback you are controlling.

Build with the Spotify node

Drop it into a workflow, wire it to an agent, or call it on a schedule. You'll need Spotify OAuth2 credentials first.

Open BusyBot

Last updated . Spotted something wrong? Tell us.