Skip to main content

Spotify CLI 🎧

Control Spotify playback on any device through the command line.

Installation

This package only supports Python 3 and above.

$ pip3 install --upgrade spotify-cli

Usage

This CLI performs all interactions through the Spotify API. All you need is a stable internet connection and an active Spotify session on any device.

Authorize the CLI & save your credentials locally.

$ spotify auth login

You may also pass your own Spotify application's client ID and secret if you want to track your usage or avoid API rate limiting issues (all users using the default client settings share the same rate limits).

When doing so, please ensure that this URL is listed as a Redirect URI in your application.

$ spotify auth login --client-id XXXXX --client-secret YYYYY

Start Spotify playback on any device and run the spotify command.

$ spotify
Usage: spotify [<options>] <command>

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  auth      Manage user authentication for spotify-cli.
  browse    Open the current track, album, artist, or playlist in the...
  devices   Manage active devices.
  history   List your recently played tracks.
  next      Play the next track in the queue.
  pause     Pause playback.
  play      Resume playback, search for a track/album/playlist, or select a...
  previous  Play the previous track in the queue.
  queue     Add a track or album to your queue.
  repeat    Turn repeat on (all/track) or off.
  save      Save a track, album, artist, or playlist.
  search    Search for any Spotify content.
  seek      Seek to time (default unit: seconds) in the current track.
  shuffle   Turn shuffle on or off.
  status    Describe the current playback session.
  toggle    Resume any paused playback, or pause it if already running.
  top       List your top tracks or artists.
  volume    Control the active device's volume level (0-100).

Examples

Describe and control current playback.

$ spotify play
Playing: Nights
         Frank Ocean - Blonde

$ spotify status -vv
Track   Nights (03:31 / 05:07)
Artist  Frank Ocean
Album   Blonde
Status  Playing (on repeat, 60% volume)

Device  Lorenzo (Smartphone)
URL:    https://open.spotify.com/track/7eqoqGkKwgOaWNNHx90uEZ

$ spotify vol up 20
Volume set to 80%

$ spotify vol to 100
Volume set to 100%

You can also manage multiple devices.

$ spotify devices -v
  LENOVO - Computer
* Lorenzo - Smartphone
  Web Player (Chrome) - Computer

$ spotify devices --switch comp
2 devices matched "comp".
? Please select the device to activate.
 > LENOVO - Computer
   Web Player (Chrome) - Computer

Switched to LENOVO - Computer

Search for a track to play, queue, or save.

$ spotify search red velvet

Search results for "red velvet"

  #  Track                                      Artist
---  -----------------------------------------  ---------------------------
  1  Psycho                                     Red Velvet
  2  Monster                                    Red Velvet - IRENE & SEULGI
  3  Bad Boy                                    Red Velvet
  4  빨간 맛 Red Flavor                         Red Velvet
  5  피카부 Peek-A-Boo                          Red Velvet
  6  Naughty                                    Red Velvet - IRENE & SEULGI
  7  Power Up                                   Red Velvet
  8  Dumb Dumb                                  Red Velvet
  9  Bad Boy - (English Version) [Bonus Track]  Red Velvet
 10  In & Out                                   Red Velvet

Actions:
[n]ext/[b]ack
[p]lay/[q]ueue/[s]ave #[,...]
[a]dd to playlist #[,...] <playlist>
: q 1,4,5

Queue the selected track/s? (1,4,5) [Y/n]: Y
3 track/s queued.

Continue searching? [Y/n]:

Some commands support search queries (play, queue, save).

$ spotify play red velvet
Playing: Psycho
         Red Velvet - ‘The ReVe Festival’ Finale

$ spotify queue --album reve finale
‘The ReVe Festival’ Finale - Red Velvet (16 tracks)
Add this album to the queue? [Y/n]: Y
Album added to queue.

$ spotify save --artist red velvet
Red Velvet
Save this artist to your library? [Y/n]: Y
Following artist - Red Velvet.

Command shortcut prefixes are supported.

# supported
spotify volume
spotify vol
spotify v

spotify next
spotify n

spotify previous
spotify prev

# not supported - too many matches (pause, play, previous)
spotify p

Some commands support the --raw flag to output the Spotify API JSON response (shell script-friendly).

$ spotify status --raw | jq .context
{
  "external_urls": {
    "spotify": "https://open.spotify.com/album/3mH6qwIy9crq0I9YQbOuDf"
  },
  "href": "https://api.spotify.com/v1/albums/3mH6qwIy9crq0I9YQbOuDf",
  "type": "album",
  "uri": "spotify:album:3mH6qwIy9crq0I9YQbOuDf"
}

Notes

  • Playback and device-related commands require at least one active Spotify session on any device.
    • You can just start and stop playback to "activate" your device.
    • Your device will remain "active" even when paused.
  • Some operations may not be supported on certain devices (i.e. volume control for mobile) and for users not subscribed to Spotify Premium.

License

The MIT License (MIT)
Copyright (c) 2020 Benj Ledesma

Metadata

Release files for spotify-cli 0.3.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spotify-cli 0.3.11
File Size Uploaded Provenance Actions
spotify-cli-0.3.11.tar.gz 21.6 kB Without provenance Details for spotify-cli-0.3.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spotify-cli 0.3.11
File Interpreter ABI Platform Actions
spotify_cli-0.3.11-py3-none-any.whl Python 3 none any Details for spotify_cli-0.3.11-py3-none-any.whl

Total release size: 53.2 kB

Release files / spotify-cli-0.3.11.tar.gz

Download URL spotify-cli-0.3.11.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d3a0ede54b164702634acb3bb5571a91ef67b8cfd7d76c0b54093d5ce9f79f20
BLAKE2b-256 checksum
How to use checksums
feb2fdcb97e8040733fd023515db22752b751431ca6b2419ba9c17c98a43d828
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

Release files / spotify_cli-0.3.11-py3-none-any.whl

Download URL spotify_cli-0.3.11-py3-none-any.whl
Size 31.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5cb0b164b72bd23f9870a6799fe4b1e9559f229ee413b7316867f45d9dda6a0a
BLAKE2b-256 checksum
How to use checksums
6301a5cd86592b8193ee8697c6c290ddc3e31b26ae6155f5128168fd0d1d29c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

Security for spotify-cli 0.3.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page