Spotify Player Control
Control Spotify playback, search music, and manage playlists.
Available Tools
- •web_fetch: Access Spotify Web API
- •bash: Use spotify-cli if installed
Spotify Web API
Base URL: https://api.spotify.com/v1/
Authentication
Get access token:
code
POST https://accounts.spotify.com/api/token
Headers:
Authorization: Basic {base64(client_id:client_secret)}
Body: grant_type=client_credentials
Common Endpoints
Get Currently Playing
code
GET https://api.spotify.com/v1/me/player/currently-playing
Headers:
Authorization: Bearer {access_token}
Search
code
GET https://api.spotify.com/v1/search?q={query}&type=track,artist,album
Play Track
code
PUT https://api.spotify.com/v1/me/player/play
Body: {"uris": ["spotify:track:{track_id}"]}
Pause
code
PUT https://api.spotify.com/v1/me/player/pause
Next/Previous
code
POST https://api.spotify.com/v1/me/player/next POST https://api.spotify.com/v1/me/player/previous
Usage Examples
User: "Play Shape of You by Ed Sheeran"
- •Search for track using /v1/search
- •Get track URI
- •Play using /v1/me/player/play
User: "What's currently playing?"
- •Fetch from /v1/me/player/currently-playing
- •Parse track info
- •Present artist, track, album
User: "Pause Spotify"
- •Call /v1/me/player/pause
Environment Setup
bash
export SPOTIFY_CLIENT_ID="your_client_id" export SPOTIFY_CLIENT_SECRET="your_client_secret"
Get credentials from: https://developer.spotify.com/dashboard
Scopes Required
For user playback control:
- •
user-read-playback-state - •
user-modify-playback-state - •
user-read-currently-playing