Loading...
Loading...
Control Spotify playback, manage playlists, search tracks, and get currently playing info via the Spotify Web API. Requires: Spotify API credentials (client ID and secret).
npx skill4agent add winsorllc/upgraded-carnival spotify-playerexport SPOTIFY_CLIENT_ID="your_client_id"
export SPOTIFY_CLIENT_SECRET="your_client_secret"# Get access token (valid 1 hour)
TOKEN=$(curl -s -X POST "https://accounts.spotify.com/api/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=$SPOTIFY_CLIENT_ID&client_secret=$SPOTIFY_CLIENT_SECRET" \
| jq -r '.access_token')
# Or use user authentication for full access
# (requires user login - more complex setup)# Get current track (requires user token)
curl -s "https://api.spotify.com/v1/me/player/currently-playing" \
-H "Authorization: Bearer $TOKEN"
# Get recently played
curl -s "https://api.spotify.com/v1/me/player/recently-played?limit=10" \
-H "Authorization: Bearer $TOKEN"
# Get user devices
curl -s "https://api.spotify.com/v1/me/player/devices" \
-H "Authorization: Bearer $TOKEN"# Play/pause (requires user token)
curl -s -X PUT "https://api.spotify.com/v1/me/player/pause" \
-H "Authorization: Bearer $TOKEN"
curl -s -X PUT "https://api.spotify.com/v1/me/player/play" \
-H "Authorization: Bearer $TOKEN"
# Next track
curl -s -X POST "https://api.spotify.com/v1/me/player/next" \
-H "Authorization: Bearer $TOKEN"
# Previous track
curl -s -X POST "https://api.spotify.com/v1/me/player/previous" \
-H "Authorization: Bearer $TOKEN"
# Seek to position (milliseconds)
curl -s -X PUT "https://api.spotify.com/v1/me/player/seek?position_ms=30000" \
-H "Authorization: Bearer $TOKEN"
# Set volume (0-100)
curl -s -X PUT "https://api.spotify.com/v1/me/player/volume?volume_percent=75" \
-H "Authorization: Bearer $TOKEN"
# Toggle shuffle
curl -s -X PUT "https://api.spotify.com/v1/me/player/shuffle?state=true" \
-H "Authorization: Bearer $TOKEN"
# Set repeat mode (off, context, track)
curl -s -X PUT "https://api.spotify.com/v1/me/player/repeat?state=context" \
-H "Authorization: Bearer $TOKEN"# Search for tracks
curl -s "https://api.spotify.com/v1/search?q=track:Shape+of+You&type=track&limit=5" \
-H "Authorization: Bearer $TOKEN" \
| jq '.tracks.items[] | {name: .name, artist: .artists[0].name, album: .album.name}'
# Search for artist
curl -s "https://api.spotify.com/v1/search?q=taylor+swift&type=artist&limit=3" \
-H "Authorization: Bearer $TOKEN" \
| jq '.artists.items[] | {name: .name, followers: .followers.total}'
# Search for album
curl -s "https://api.spotify.com/v1/search?q=album:1989&type=album&limit=5" \
-H "Authorization: Bearer $TOKEN"# Get track details
curl -s "https://api.spotify.com/v1/tracks/TRACK_ID" \
-H "Authorization: Bearer $TOKEN"
# Get artist details
curl -s "https://api.spotify.com/v1/artists/ARTIST_ID" \
-H "Authorization: Bearer $TOKEN"
# Get album details
curl -s "https://api.spotify.com/v1/albums/ALBUM_ID" \
-H "Authorization: Bearer $TOKEN"
# Get artist albums
curl -s "https://api.spotify.com/v1/artists/ARTIST_ID/albums?limit=10" \
-H "Authorization: Bearer $TOKEN"# Get queue
curl -s "https://api.spotify.com/v1/me/player/queue" \
-H "Authorization: Bearer $TOKEN"
# Add to queue
curl -s -X POST "https://api.spotify.com/v1/me/player/queue?uri=spotify:track:TRACK_ID" \
-H "Authorization: Bearer $TOKEN"# Get user playlists
curl -s "https://api.spotify.com/v1/me/playlists?limit=50" \
-H "Authorization: Bearer $TOKEN"
# Get playlist tracks
curl -s "https://api.spotify.com/v1/playlists/PLAYLIST_ID/tracks?limit=50" \
-H "Authorization: Bearer $TOKEN"
# Get playlist details
curl -s "https://api.spotify.com/v1/playlists/PLAYLIST_ID" \
-H "Authorization: Bearer $TOKEN"
# Create playlist (requires user token)
curl -s -X POST "https://api.spotify.com/v1/users/USER_ID/playlists" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "My New Playlist", "description": "Created by agent", "public": false}'
# Add track to playlist
curl -s -X POST "https://api.spotify.com/v1/playlists/PLAYLIST_ID/tracks?uris=spotify:track:TRACK_ID" \
-H "Authorization: Bearer $TOKEN"# Get current user profile
curl -s "https://api.spotify.com/v1/me" \
-H "Authorization: Bearer $TOKEN"
# Get user saved tracks
curl -s "https://api.spotify.com/v1/me/tracks?limit=50" \
-H "Authorization: Bearer $TOKEN"
# Get user saved albums
curl -s "https://api.spotify.com/v1/me/albums?limit=50" \
-H "Authorization: Bearer $TOKEN"
# Get user saved artists
curl -s "https://api.spotify.com/v1/me/artists?limit=50" \
-H "Authorization: Bearer $TOKEN"# Get access token
spotify_token() {
curl -s -X POST "https://accounts.spotify.com/api/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=$SPOTIFY_CLIENT_ID&client_secret=$SPOTIFY_CLIENT_SECRET" \
| jq -r '.access_token'
}
# Search and play first result (requires user token + device)
spotify_play_track() {
QUERY=$1
TRACK_URI=$(curl -s "https://api.spotify.com/v1/search?q=$QUERY&type=track&limit=1" \
-H "Authorization: Bearer $TOKEN" \
| jq -r '.tracks.items[0].uri')
curl -s -X PUT "https://api.spotify.com/v1/me/player/play?device_id=DEVICE_ID" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"uris\": [\"$TRACK_URI\"]}"
}
# Get now playing info
spotify_now() {
curl -s "https://api.spotify.com/v1/me/player/currently-playing" \
-H "Authorization: Bearer $TOKEN" \
| jq '{song: .item.name, artist: .item.artists[0].name, album: .item.album.name, progress: .progress_ms, duration: .item.duration_ms}'
}| Action | Method | Endpoint |
|---|---|---|
| Get current track | GET | |
| Play | PUT | |
| Pause | PUT | |
| Next | POST | |
| Previous | POST | |
| Volume | PUT | |
| Search | GET | |
| Get track | GET | |
| Playlists | GET | |