Skip to content
COMMAND REFERENCE

Command Reference

Control Spotify playback, manage your library, search the catalog, and build automations — all from the command line. Every command returns structured JSON.

sh
$ spotify <command> [options]

Authentication 3 commands

Manage OAuth tokens and session state. All auth data is stored locally — nothing is sent to third-party servers.

login AUTH

Authenticate with Spotify using OAuth 2.0 PKCE. Opens browser to authorize, then stores tokens locally.

sh
$ spotify login [--client-id <id>]
OptionTypeDescription
--client-idstringUse a custom Spotify app client ID

OUTPUT

json
{ "status": "logged_in", "expires_at": 1700000000, "scope": "user-read-playback-state ..." }

logout AUTH

Clear stored OAuth tokens from disk.

sh
$ spotify logout

OUTPUT

json
{ "status": "logged_out" }

auth status AUTH

Show current token validity and granted OAuth scopes.

sh
$ spotify auth status

OUTPUT

json
{ "status": "valid", "expires_at": 1700000000, "scope": ["user-read-playback-state", "user-modify-playback-state", "..."] }

Player 14 commands

Control playback, manage the queue, and interact with Spotify Connect devices. Most commands accept an optional --device flag to target a specific device.

now PLAYER

Get the currently playing track with playback state.

sh
$ spotify now
json
{
  "item": {
    "name": "Bohemian Rhapsody",
    "artists": [{ "name": "Queen" }],
    "album": { "name": "A Night at the Opera" }
  },
  "is_playing": true,
  "progress_ms": 42000
}

play PLAYER

Start or resume playback with optional targeting.

sh
$ spotify play [--uri <uri>] [--context <uri>] [--device <id>] [--offset <n>] [--position <ms>]
OptionTypeDescription
--uristringSpotify URI of a track to play
--contextstringContext URI (album, playlist, artist)
--devicestringTarget device ID
--offsetintegerZero-based track offset within context
--positionintegerStart position in milliseconds

pause PLAYER

Pause playback on the active device.

sh
$ spotify pause [--device <id>]

next PLAYER

Skip to the next track in the queue.

sh
$ spotify next [--device <id>]

prev PLAYER

Skip to the previous track.

sh
$ spotify prev [--device <id>]

seek PLAYER

Seek to a position in the current track.

sh
$ spotify seek <ms> [--device <id>]
OptionTypeDescription
<ms>integerPosition in milliseconds (non-negative)
--devicestringTarget device ID

volume PLAYER

Set playback volume (0–100).

sh
$ spotify volume <0-100> [--device <id>]
OptionTypeDescription
<0-100>integerVolume level (0–100)
--devicestringTarget device ID

shuffle PLAYER

Toggle shuffle mode on or off.

sh
$ spotify shuffle <on|off> [--device <id>]

repeat PLAYER

Set repeat mode: off, track, or context.

sh
$ spotify repeat <off|track|context> [--device <id>]

queue PLAYER

Show the current playback queue.

sh
$ spotify queue

queue add PLAYER

Add a track to the end of the playback queue.

sh
$ spotify queue add <uri> [--device <id>]

devices PLAYER

List all available Spotify Connect devices.

sh
$ spotify devices

transfer PLAYER

Transfer playback to a different device.

sh
$ spotify transfer <device_id> [--play]
OptionTypeDescription
<device_id>stringTarget device ID
--playbooleanStart playback on the new device

recent PLAYER

Recently played tracks with optional cursor-based pagination.

sh
$ spotify recent [--limit <n>] [--after <timestamp>] [--before <timestamp>]
OptionTypeDescription
--limitintegerNumber of items to return
--afterintegerUnix timestamp — return items after this
--beforeintegerUnix timestamp — return items before this

Full-text search across the Spotify catalog. Supports tracks, albums, artists, and playlists.

search SEARCH

Search the Spotify catalog. Defaults to searching for tracks.

sh
$ spotify search <query> [--type <type>] [--limit <n>] [--offset <n>]
OptionTypeDefaultDescription
<query>stringSearch query (multiple words joined)
--typestringtrackComma-separated types: track, album, artist, playlist
--limitintegerNumber of results to return
--offsetintegerResult offset for pagination
sh
$ spotify search "Miles Davis" --type artist --limit 3
json
{
  "artists": {
    "items": [
      { "name": "Miles Davis", "uri": "spotify:artist:0kbYTNQb1g4...", "popularity": 72 }
    ]
  }
}

Tracks 6 commands

Look up individual tracks, analyze audio features, get recommendations, and manage your saved library.

track TRACKS

Get detailed track metadata.

sh
$ spotify track <id>

track features TRACKS

Get audio analysis features for a track.

sh
$ spotify track features <id>

Deprecated

Spotify removed access to the Audio Features API for most apps in November 2024. This command may return a 403 error.

json
{
  "danceability": 0.735,
  "energy": 0.578,
  "key": 5,
  "loudness": -5.883,
  "tempo": 120.08,
  "valence": 0.624,
  "acousticness": 0.014
}

track recommendations TRACKS

Get track recommendations based on seed tracks, artists, or genres. At least one seed type is required.

sh
$ spotify track recommendations --seed-tracks <ids> --seed-artists <ids> --seed-genres <genres> [--limit <n>]
OptionTypeDescription
--seed-tracksstringComma-separated track IDs
--seed-artistsstringComma-separated artist IDs
--seed-genresstringComma-separated genre names
--limitintegerNumber of recommendations

Deprecated

Spotify removed access to the Recommendations API for most apps in November 2024. This command may return a 403 or 404 error.

track saved TRACKS

List saved tracks in your library.

sh
$ spotify track saved [--limit <n>] [--offset <n>]

track save TRACKS

Save one or more tracks to your library.

sh
$ spotify track save <id...>

track remove TRACKS

Remove one or more tracks from your library.

sh
$ spotify track remove <id...>

Albums 5 commands

Fetch album metadata, list album tracks, and manage your saved album library.

album ALBUMS

Get album details and metadata.

sh
$ spotify album <id>

album tracks ALBUMS

List all tracks in an album.

sh
$ spotify album tracks <id> [--limit <n>] [--offset <n>]

album saved ALBUMS

List saved albums in your library.

sh
$ spotify album saved [--limit <n>] [--offset <n>]

album save ALBUMS

Save one or more albums to your library.

sh
$ spotify album save <id...>

album remove ALBUMS

Remove one or more albums from your library.

sh
$ spotify album remove <id...>

Playlists 6 commands

Create, modify, and browse playlists. Supports adding and removing tracks by URI, name match, or index position.

playlist PLAYLISTS

Get playlist details and metadata.

sh
$ spotify playlist <id>

playlist list PLAYLISTS

List your playlists.

sh
$ spotify playlist list [--limit <n>] [--offset <n>]

playlist tracks PLAYLISTS

List tracks in a playlist.

sh
$ spotify playlist tracks <id> [--limit <n>] [--offset <n>]

playlist add PLAYLISTS

Add tracks to a playlist at an optional position.

sh
$ spotify playlist add <playlist_id> <uri...> [--position <n>]
OptionTypeDescription
<playlist_id>stringTarget playlist ID
<uri...>stringOne or more Spotify track URIs
--positionintegerZero-based insert position

playlist remove PLAYLISTS

Remove tracks from a playlist by URI, name match, or index.

sh
$ spotify playlist remove <playlist_id> [uri...] [--match <name>] [--index <n>]
OptionTypeDescription
<playlist_id>stringTarget playlist ID
[uri...]stringTrack URIs to remove
--matchstringRemove tracks matching name or artist name (repeatable)
--indexstringRemove tracks at 1-based positions (comma-separated, repeatable)

At least one of uri, --match, or --index is required.

sh
# Remove by name match
$ spotify playlist remove 37i9dQZF1DXcBWIGoYBM5M --match "Bohemian"

# Remove by index
$ spotify playlist remove 37i9dQZF1DXcBWIGoYBM5M --index 1,3,5

playlist create PLAYLISTS

Create a new playlist.

sh
$ spotify playlist create <name> [--description <text>] [--public]
OptionTypeDescription
<name>stringPlaylist name
--descriptionstringPlaylist description
--publicbooleanMake the playlist public

User 5 commands

View your profile, top listening stats, and manage artist follows.

me USER

Get the current user's profile.

sh
$ spotify me

top USER

Your top artists or tracks over different time ranges.

sh
$ spotify top <artists|tracks> [--time-range <range>] [--limit <n>] [--offset <n>]
OptionTypeDefaultDescription
<artists|tracks>stringItem type
--time-rangestringmedium_termshort_term (4 weeks), medium_term (6 months), long_term (all time)
--limitintegerNumber of items
--offsetintegerResult offset
json
{
  "items": [
    { "name": "Radiohead", "uri": "spotify:artist:4Z8W4fKeB5YxbusRsdQVPb", "popularity": 82 }
  ]
}

following USER

List followed artists.

sh
$ spotify following [--limit <n>] [--after <artist_id>]
OptionTypeDescription
--limitintegerNumber of items
--afterstringCursor — last artist ID from previous page

follow USER

Follow one or more artists.

sh
$ spotify follow <id...>

unfollow USER

Unfollow one or more artists.

sh
$ spotify unfollow <id...>

Exit Codes

All commands use consistent exit codes for scripting and automation.

CodeNameMeaning
0SUCCESSCommand completed successfully
1ARGSInvalid arguments or missing required options
2AUTHNot logged in or token expired
3APISpotify API returned an error (4xx/5xx)
4NETWORKNetwork connectivity failure

Errors are written to stderr as JSON:

json
{ "error": "No active device found", "details": { "status": 404 } }

MIT Licensed. Not affiliated with or endorsed by Spotify AB.