canonical: https://jentic.com/apis/spotify.com/spotify

# Spotify Web API

Discover music, podcasts, and audiobooks, control playback across devices, and manage personal libraries through 89 endpoints spanning the Spotify platform. The API provides access to Spotify's catalog of 100+ million tracks with search, recommendations, audio features analysis, and playlist management. OAuth 2.0 authorization code flow enables user-scoped actions including playback control via Spotify Connect, library curation, and listening history retrieval.

## For AI agents

Search Spotify's catalog of tracks, albums, artists, and podcasts, control playback across devices, and manage user playlists and libraries. Covers 89 endpoints with OAuth 2.0 user-scoped access.

## Scope

Does not handle music licensing, royalty payments, or audio file downloads - use for catalog discovery, playback control, and library management only.

## Capabilities

- Search the Spotify catalog across tracks, albums, artists, shows, episodes, and audiobooks with filtered queries
- Control playback on any Spotify Connect device including play, pause, skip, seek, volume, and queue management
- Build and modify playlists with track ordering, collaborative editing, and custom cover images
- Retrieve audio features (danceability, energy, tempo, valence) and audio analysis for algorithmic music discovery
- Access personalized recommendations based on seed tracks, artists, and genres with tunable attributes
- Track listening history through recently played items, top artists, and top tracks over different time ranges

## Use cases

### AI Agent Music Discovery and Playlist Curation

AI agents build personalized playlists by combining Spotify's recommendation engine with audio feature analysis through Jentic. The agent searches for tracks matching target mood attributes (valence, energy, danceability), retrieves recommendations seeded from user favorites, and assembles a playlist - all without the user manually browsing the Spotify catalog. Jentic handles OAuth token management so the agent can access user-scoped endpoints.

Example prompt: Get the user's top 5 tracks via GET /me/top/tracks, use them as seeds in GET /recommendations with target_energy=0.8, then create a playlist via POST /users/{user_id}/playlists and add the recommended tracks via POST /playlists/{playlist_id}/tracks

### Cross-Device Playback Control

Control Spotify playback across all connected devices through the Spotify Connect protocol. The Player endpoints enable starting, pausing, skipping, seeking, and adjusting volume on any active device - phones, speakers, desktops, or smart displays. The API exposes the full device list with current volume and active status, enabling automated playback routing and multi-room audio orchestration without the Spotify app UI.

Example prompt: List available devices via GET /me/player/devices, transfer playback to a specific device via PUT /me/player with device_ids, then start playing a specific album via PUT /me/player/play with context_uri

### Audio Feature Analysis for Music Apps

Analyze the musical characteristics of any track in Spotify's catalog using audio features (tempo, key, time signature, danceability, energy, valence, speechiness, acousticness, instrumentalness, liveness) and detailed audio analysis (beats, bars, sections, segments). These features power mood-based filtering, BPM matching for DJ tools, workout playlists by energy level, and music education applications.

Example prompt: Retrieve audio features for 5 tracks via GET /audio-features?ids={id1},{id2},..., filter by danceability > 0.7 and energy > 0.6, and return the matching tracks

### Podcast and Audiobook Discovery

Search and browse Spotify's podcast and audiobook catalog with the same API used for music. The search endpoint supports type filtering for shows, episodes, and audiobooks. Users can save shows to their library, track listening progress with playback position, and discover new content through Spotify's recommendation algorithms applied to spoken-word content.

Example prompt: Search for podcasts about AI using GET /search?q=artificial+intelligence&type=show, then retrieve episodes for the top result via GET /shows/{id}/episodes and check if any are in the user's library via GET /me/episodes/contains

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | /search | Search the catalog for tracks, albums, artists, shows, or audiobooks |
| GET | /recommendations | Get track recommendations based on seeds and tunable attributes |
| GET | /me/player | Get current playback state and active device |
| PUT | /me/player/play | Start or resume playback on a device |
| POST | /playlists/{playlist_id}/tracks | Add tracks to a playlist |
| GET | /audio-features/{id} | Get audio features for a track |
| GET | /me/top/tracks | Get user's top tracks by listening frequency |
| GET | /artists/{id}/top-tracks | Get an artist's top tracks by country |

## Key resources

- **Tracks** — Individual songs with audio features, audio analysis, and saved-state management
- **Albums** — Album metadata, track listings, and user library state
- **Artists** — Artist profiles, discographies, top tracks, and related artists
- **Playlists** — Create, modify, and follow playlists with collaborative editing and cover images
- **Player** — Playback control across Spotify Connect devices - play, pause, skip, queue, volume, shuffle, repeat
- **Search** — Full-catalog search across tracks, albums, artists, shows, episodes, and audiobooks

## Why Jentic

- **Setup:** Wiring the Spotify Web API by hand means implementing its OAuth 2.0 flow, tracking the scopes each endpoint needs, refreshing user tokens, and pointing every call at the api.spotify.com/v1 host yourself. Through Jentic you install once, import the Spotify Web API from the API Directory, store the OAuth credential once, and your agent calls it.
- **Permission scoping:** Spotify puts the playlist id in the URL path (/playlists/{playlist_id}/tracks), so a rule can pin your agent to one playlist for track changes. You choose the operations it may call, so playback control like starting or transferring playback is not included unless you add it.
- **Credential handling:** Your Spotify OAuth client credentials and user tokens are stored once, encrypted, by your own Jentic One instance and injected at execution time. The client secret and refresh token never enter the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'search the catalog' or 'add tracks to a playlist', and Jentic returns the matching Spotify Web API operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **SoundCloud API** — Audio streaming platform focused on independent creators and user-generated music content
- **Musixmatch API** — Song lyrics and metadata database for enriching Spotify track data with synchronized lyrics
- **Deepgram API** — Speech-to-text transcription for generating searchable transcripts from podcast episodes

## FAQ

### What authentication does the Spotify Web API use?

The Spotify Web API uses OAuth 2.0 with the authorization code flow for user-scoped access. It defines 19 scopes covering playback control, library management, playlist editing, user data access, and content upload. Access tokens expire after one hour and must be refreshed. Through Jentic, OAuth tokens and refresh cycles are managed in your Jentic One instance - agents receive scoped access tokens without handling the OAuth dance.

### Can I control playback on a specific device via the API?

Yes. GET /me/player/devices returns all active Spotify Connect devices with their IDs, names, and volume. Transfer playback with PUT /me/player passing the target device_id. Then use PUT /me/player/play, POST /me/player/pause, POST /me/player/next, POST /me/player/previous, and PUT /me/player/seek to control playback. Requires the user-modify-playback-state scope.

### What are the rate limits for the Spotify Web API?

Spotify applies rate limits based on a rolling 30-second window. The exact limits vary by endpoint and app category. When exceeded, the API returns HTTP 429 with a Retry-After header indicating seconds to wait. Typical apps get approximately 180 requests per minute for most endpoints. Web API status endpoints and search may have different thresholds.

### How do I build a recommendation playlist through Jentic?

Install the Jentic SDK with pip install jentic, then search for 'get music recommendations from spotify'. Jentic returns the GET /recommendations endpoint schema with seed_tracks, seed_artists, seed_genres parameters and tunable attributes (target_energy, target_valence, etc.). The agent constructs the request, receives recommended track URIs, and calls POST /playlists/{playlist_id}/tracks to populate a playlist.

### Can I access audio analysis data for any track?

Yes. GET /audio-features/{id} returns high-level attributes (danceability, energy, tempo, key, time signature, valence) for any track. GET /audio-analysis/{id} returns detailed timing data including beats, bars, sections, and segments with pitch and timbre vectors. Both endpoints work with any track in Spotify's catalog regardless of user authorization.

### Does the API support podcast and audiobook content?

Yes. The search endpoint accepts type=show for podcasts and type=audiobook for audiobooks. Dedicated endpoints exist for retrieving show details (GET /shows/{id}), episodes (GET /shows/{id}/episodes), audiobook chapters (GET /audiobooks/{id}/chapters), and managing saved shows and audiobooks in the user's library.

### Can I limit what my agent is allowed to do with the Spotify Web API?

Yes. Jentic One is self-hosted, so your own rules decide which Spotify operations and credentials the agent may use. Because Spotify puts the playlist id in the URL path (/playlists/{playlist_id}/tracks), you can pin the agent to a single playlist for track changes, and you choose exactly which operations it may call. Playback control such as starting or transferring playback (PUT /me/player/play, PUT /me/player) is not available to the agent unless you explicitly add it.
