OpenClaw and Spotify - Your AI Music DJ
Turning Your Agent into a Music Companion
Spotify's API is one of the most feature-rich music APIs available. It exposes everything from playback control and playlist management to detailed audio analysis of individual tracks. By connecting OpenClaw to Spotify through a community-built skill, your agent becomes a music assistant that can manage your playlists, control playback, and help you discover new music -- all through natural conversation.
This is not just remote control for Spotify. Because your OpenClaw agent understands context and can reason about your requests, you can ask for things like "make a playlist for a rainy Sunday morning" or "find me something similar to what I was listening to last week but more upbeat." The agent uses Spotify's API endpoints to translate these requests into concrete actions.
Setting Up the Spotify Connection
Connecting OpenClaw to Spotify requires a Spotify Developer application and OAuth authentication.
Creating a Spotify App
- Go to the Spotify Developer Dashboard and create a new application
- Set a redirect URI (this will be used during the OAuth flow)
- Note your Client ID and Client Secret
- Select the Web API scope
OAuth Authentication
Spotify uses OAuth 2.0 with authorization code flow. The community Spotify skill for OpenClaw handles the OAuth token exchange and refresh cycle. During initial setup, you will need to authorize the skill to access your Spotify account by logging in through a browser. After that, the skill manages token refresh automatically.
The required scopes depend on what you want to do:
- user-read-playback-state and user-modify-playback-state: Control playback (play, pause, skip, volume)
- playlist-read-private and playlist-modify-private: Read and create playlists
- user-library-read and user-library-modify: Access your saved tracks and albums
- user-read-recently-played: See your listening history
- user-top-read: Access your top artists and tracks
Installing the Skill
Search for the Spotify skill in ClawHub and install it on your OpenClaw instance. Configure it with your Client ID, Client Secret, and the OAuth tokens obtained during setup. The skill exposes actions covering playback control, playlist management, library access, search, and track analysis.
Playlist Management
Playlists are the heart of how most people organize their music on Spotify. Your OpenClaw agent can create, modify, and curate playlists based on your instructions.
Creating Playlists by Description
Tell your agent what kind of playlist you want, and it will build one. "Create a playlist of 90s alternative rock for a road trip" -- the agent searches Spotify for tracks matching that description, selects a mix of popular and deeper cuts, and creates a new playlist in your account. You can refine it: "add more Radiohead" or "remove anything too slow."
The quality of these playlists depends on how specific you are. Vague requests like "good music" produce generic results. Specific requests like "instrumental post-rock from the 2010s, no vocals, tracks over 5 minutes" produce much more targeted lists.
Maintaining Existing Playlists
If you have a playlist that needs regular updates -- a monthly favorites list, a workout playlist that is getting stale, or a collaborative playlist for your friend group -- your agent can help maintain it. "Add some new tracks to my workout playlist" triggers the agent to look at what is already there, identify the general style and energy level, and find fresh tracks that fit.
Duplicate Detection
Long-running playlists often accumulate duplicate tracks. Your agent can scan a playlist, identify duplicates, and remove them. It can also flag tracks that are very similar (same song, different album version) so you can decide which to keep.
Playlist Organization
If you have dozens of playlists and want to reorganize them, your agent can help. "Merge my 'Morning Chill' and 'Coffee Shop' playlists" or "Split my 'Everything' playlist into separate genre playlists." The agent handles the track copying and optional cleanup.
Playback Control
Basic playback control is simple but the conversational interface makes it smoother than reaching for your phone.
Standard Controls
Play, pause, skip forward, skip back, adjust volume, toggle shuffle, toggle repeat -- all through conversation. These are the commands you would expect, and they work across whatever device is currently active on your Spotify account.
Device Selection
Spotify Connect lets you play music on different devices -- your phone, computer, smart speaker, or TV. Your agent can list your available devices and switch playback between them. "Play this on the living room speaker" or "switch my music to my laptop."
Queue Management
Managing the Spotify queue through the mobile app is awkward. Your agent makes it conversational: "add this song to the queue," "what is coming up next?", "clear the queue and start fresh with this album." The agent handles the API calls to manipulate the playback queue.
Music Discovery
Finding new music you actually like is one of the most valuable things a Spotify integration can do.
Recommendation Engine
Spotify's recommendation API accepts seed tracks, artists, or genres along with tunable parameters like energy, danceability, tempo, and valence (musical positivity). Your agent translates your natural language requests into these parameters. "Find me something energetic but not too aggressive" becomes a recommendation request with high energy, moderate danceability, and medium valence.
Discovery Based on Listening History
Your agent can analyze your recent listening history and top tracks to find patterns. "I have been listening to a lot of jazz lately -- find me some jazz artists I haven't heard." The agent checks your recently played tracks, identifies the jazz artists you have been listening to, and searches for similar artists you have not played before.
Exploring an Artist's Catalog
When you discover an artist you like, your agent can dive deeper. "Tell me about Khruangbin's discography" or "what are the deep cuts from this artist that most people miss?" The agent can pull up an artist's full catalog, sort by popularity, and surface less-played tracks that deserve attention.
Audio Feature Analysis
Spotify provides audio features for every track -- tempo, key, danceability, energy, acousticness, instrumentalness, and more. Your agent can use these to answer specific questions: "What is the tempo of this song?", "Find me tracks in the same key as this one," or "Which songs in this playlist have the highest energy?" This is particularly useful for DJs or anyone building playlists with specific sonic characteristics.
Mood-Based Music
One of the most natural ways to ask for music is by describing how you feel or what you are doing.
Mood Mapping
Your agent maps mood descriptions to Spotify's audio feature parameters:
- "Relaxing" maps to low energy, high acousticness, low tempo
- "Pumped up" maps to high energy, high danceability, high tempo
- "Melancholic" maps to low valence, moderate energy, minor key preference
- "Focused" maps to high instrumentalness, moderate tempo, low speechiness
These are not rigid mappings -- the agent uses them as starting points and adjusts based on additional context you provide.
Activity-Based Selection
"I am going for a run" or "I need music for cooking dinner" -- the agent selects music appropriate for the activity. Running gets high-tempo, high-energy tracks. Cooking might get something upbeat but not overwhelming. Studying gets instrumental or ambient music.
Time-of-Day Awareness
If you tell your agent what time it is or let it infer from context, it can adjust recommendations accordingly. Morning music tends toward gentler, more positive tracks. Late night might suggest more atmospheric or downtempo selections.
Listening Statistics and Insights
Spotify tracks a lot of data about your listening habits. Your agent can make sense of it.
Personal Analytics
"What have I been listening to most this month?" or "Who are my top artists this year?" The agent queries Spotify's top items endpoints and presents your listening data. Unlike Spotify Wrapped, which only comes once a year, you can ask for this analysis anytime.
Playlist Analytics
For any playlist, your agent can calculate aggregate statistics: average tempo, most common genres, total duration, energy distribution, and variety score. This is useful for understanding the character of a playlist and identifying opportunities to improve it.
Listening Patterns
Over time, your agent can track how your listening habits change. "Am I listening to more electronic music than I used to?" or "How has my average song tempo changed over the last few months?" These insights help you understand your own musical preferences better.
Party and Social Features
Collaborative Queue Management
At a party or gathering, your agent can manage a shared queue. Guests tell the agent what they want to hear, and it adds tracks to the queue while maintaining a reasonable flow -- avoiding jarring transitions between wildly different genres. You can set guardrails: "nothing too aggressive, keep it upbeat, no songs longer than 5 minutes."
DJ Transitions
For more curated listening experiences, your agent can build playlists that flow well from track to track, matching tempos, keys, and energy levels for smooth transitions. This is not professional DJ software, but for casual listening it creates a noticeably more cohesive experience.
Practical Considerations
API Rate Limits
Spotify's API has rate limits. For normal personal use, you are unlikely to hit them. But if you set up automations that make frequent API calls (like monitoring playback state every few seconds), you may need to add some throttling. The community skill handles basic rate limit compliance.
Premium Required for Playback Control
Spotify's API requires a Premium subscription for playback control features (play, pause, skip, device transfer). Read-only features like viewing playlists, searching, and getting recommendations work with a free account. If you are on Spotify Free, you can still use the agent for playlist creation and music discovery.
Regional Availability
Some tracks and features may not be available in all regions. If your agent tries to add a track that is not available in your market, the Spotify API returns an error. The agent can handle this gracefully and suggest alternatives.
Getting Started
- Create a Spotify Developer app and note your credentials
- Install the Spotify skill from ClawHub
- Complete the OAuth flow to authorize the skill
- Start with search and playlists -- create a playlist based on a description
- Try playback control -- play, pause, and skip from your agent chat
- Explore recommendations -- ask for music based on mood, activity, or similar artists
The Spotify integration turns your OpenClaw agent into a music companion that knows the entire Spotify catalog and responds to natural language. Whether you want a quick playlist for your commute or a deep dive into a new genre, your agent handles the search, selection, and organization so you can just listen.