winget install --id=Envoy49.go-spotify-cli -e
Go Spotify CLI is a command-line interface tool built with GoLang (v1.21) that interfaces with the Spotify Web API, allowing users to control playback, manage devices, and more.
Go Spotify CLI is a command-line interface tool built with GoLang (v1.21) that interfaces with the Spotify Web API, enabling users to control playback, manage devices, search for tracks, and more directly from the terminal.
Key Features:
Audience & Benefit: Ideal for users who prefer command-line tools for hands-free operation, efficient workflow, and direct access to Spotify functionality. This tool provides a powerful way to interact with Spotify without relying on graphical interfaces, offering flexibility and ease of use for managing music playback and device control.
Go Spotify CLI is a command-line interface tool built with GoLang (v1.21) that interfaces with the Spotify Web API, allowing users to control playback, manage devices, and more.
For any questions, suggestions, or collaborations, feel free to reach out to me on Discord!
ClientId
and ClientSecret
.Mac
, π§ Linux
, πͺ Windows
go install
methodgo install github.com/envoy49/go-spotify-cli@latest
go install github.com/envoy49/go-spotify-cli@
After the installation is complete, open a new terminal and run go-spotify-cli --version
.
Mac
Brew package manager is required to install Go Spotify CLI. More information on steps to download brew can be found here: https://brew.sh/
Once brew is installed, below steps are required for installation.
brew tap Envoy49/homebrew-go-spotify-cli
brew install go-spotify-cli
After the installation is complete, open a new terminal and run go-spotify-cli --version
.
Update
brew update
brew upgrade go-spotify-cli
Uninstall
brew uninstall go-spotify-cli
Linux
π§ͺ At the moment only go install
method is available although Homebrew can be tried.
Windows
Winget Installation Guide
More information can be found here: Winget CLI
Paste the following command into the PowerShell window to install Winget and press Enter:
winget install wingetcreate
Once Winget is installed, below steps are required for installation.
Search
winget search go-spotify-cli
Installation
winget install Envoy49.go-spotify-cli
After the installation is complete, open a new terminal and run go-spotify-cli --version
.
Update
winget upgrade Envoy49.go-spotify-cli
Uninstall
winget uninstall Envoy49.go-spotify-cli
> Note π: go-spotify-cli --version
command is hardcoded at this point until the issue with dynamic assignment is resolved.
To get started, you'll need a 'Client ID' and 'Client Secret' from Spotify's Developer Dashboard:
π Navigate to: Spotify Developer Dashboard
πͺ Sign in or create a Spotify account.
β Click on 'Create An App'.
π Fill in the app details.
β In the app settings, set your Redirect URIs. Ensure your CLI tool's callback URL is added. App won't work without redirect URLs.
π Authenticate with Spotify. In the Redirect URIs field of the app you created, please enter the following URLs:
http://localhost:4949/user-modify-playback-state-auth-callback
http://localhost:4949/user-read-playback-state-auth-callback
http://localhost:4949/user-library-read-auth-callback
π Once the App is created, you'll find the 'Client ID' and 'Client Secret' on the app details page.
π Input Credentials:
ClientId
and ClientSecret
..go-spotify-cli
folder in the root directory for future use.π« Remember: Keep your 'Client Secret and Client Id' confidential. Never share it! They are a key to control your Spotify data.
>Note: π If secrets entered are wrong although validation is in place, go-spotify-cli flush-secrets
command can be used to delete saved secrets to start process again.
π On the first run, Go Spotify CLI will initiate an authentication process through the Spotify interface. A browser window will open, requesting access grant. Once access is granted, Spotify will issue a 1-hour auth token along with a refresh token. The refresh token will be used to obtain a new token after the original token has expired. This ensures that browser authentication is no longer required after initial access has been granted.
>Note: π Tokens are stored in the .go-spotify-cli
folder of root directory.
Type go-spotify-cli
+ ``
βΆοΈ play
: Starts playback on the current device.
βΈοΈ pause
: Pauses playback on the current device.
β© next
: Skips to the next track.
βͺ previous
: Returns to the previous track.
π volume
: Adjusts volume (0-100). Usage: example: volume -v=80
.
π± device
: Activates a specific device from provided options. E.g. laptop, tablet, phone etc.
πΎ saved
: Prints a list of saved tracks and allows to play selected track.
π search
: Search any Tracks
and Episodes
. Searching Artists
, Albums
, Playlists
, Shows
are not available yet. Any selected song from search result will be added to the current queue.
π flush-tokens
: This command will delete all token saved in .go-spotify-cli
folder. Further commands will require a new browser authentication.
π flush-secrets
: This command will delete all secrets saved in .go-spotify-cli
folder.
>Note: πTo make executing commands more convenient, aliases can be utilized.
The CLI communicates with the following Spotify API Endpoints:
/v1/me/player/play
/v1/me/player/pause
/v1/me/player/next
/v1/me/player/previous
/v1/me/player/volume
/v1/me/player/devices
/v1/me/tracks
Note: π More endpoints and functionality will be added once this project gains 25 stars.
Your contributions light up our world! π Feel free to submit pull requests or raise issues. There are still a lot of endpoints which can be implemented and a lot of room for improvement.
go mod tidy
Configuration
steps mentioned abovego run main.go play
Artists
, Albums
, Playlists
, Shows
.This project is under the MIT License. Dive into the LICENSE
file for more.