
SpotAPI
Async Python client for Spotify's private API
Replaces —
Who it's for
A developer who wants to query the Spotify catalogue, fetch track credits, or inspect public playlists from a script or CLI without registering a Spotify app or holding a Premium subscription.
User needs official OAuth scopes or Spotify-approved production access.
The mix-map example uses `Public` to fetch audio analysis for public playlist tracks and finds harmonically compatible transitions with tempo shift guidance. The duplicate-aware playlist API lets curators move or remove individual occurrences of repeated tracks.
User requires audio rendering or direct track download.
The player examples and `Private.stats` enable live now-playing widgets, personal top-track dashboards, and listening history views using an authenticated session cookie.
User needs multi-user OAuth flows or long-lived refresh tokens.
The included MCP server Docker image lets AI agents call SpotAPI for search, credits, and playlist data as part of a larger tool-use workflow.
The problem
Since February 2026, Spotify's official Web API Development Mode limits each Client ID to five authorized users, requires the app owner to hold a Premium subscription, and caps developers at 25 apps. This makes it impractical to build personal tools, public catalogues, or small-scale music apps through the official route. SpotAPI addresses this by targeting Spotify's web-player endpoints directly, which require no developer app for public data and impose no per-client user cap.
How it works
Search, artist and album lookups, credit reads, and public playlist access all work anonymously. The first request discovers Spotify's current web-player queries; subsequent calls reuse the cached queries for the same Spotify build.
Every response is a typed model, not a raw dictionary. Reading a field never triggers a hidden HTTP request, and optional metadata stays optional. Requires Python 3.11 or newer.
`Playlist.items()` returns occurrence IDs so `move_occurrences()` and `remove_occurrences()` can target one copy of a repeated track without affecting its duplicate.
`Private.from_cookies()` opens an authenticated session using a Spotify session cookie. It exposes liked songs, personal top-track rankings, playlist mutations, and live player events.
`spotapi discover` launches a keyboard-driven Textual UI for browsing public search results. The CLI also covers credits, playlist management, library listing, and player status without any extra setup.
The `spotapi[studio]` extra opens a native-WebView desktop app for reading track credits, following artist and album links, viewing timed lyrics, and seeking to a line on a connected Spotify player.
Features
- No API key for public data
- Fully typed async results
- Duplicate-aware playlist editing
- Authenticated account access
- Built-in CLI and terminal UI
- Studio desktop viewer
How to install
python -m pip install spotapi spotapi search "Daft Punk"
Recommended for this setup
Strengths
- No developer dashboard required: Public operations need only `pip install spotapi`. There is no Spotify app to register, no Client ID to wire up, and no user cap to manage for catalogue and search use cases.
- Safe concurrent context management: `Catalogue` and `Private` are async context managers that open and close their own HTTP sessions. Sharing one `Catalogue` instance across operations avoids redundant connections inside a long-running application.
- Transparent v1 migration path: Existing synchronous v1 scripts can pin `spotapi==1.2.8` while rewriting. New code that cannot adopt `asyncio` can use the `SyncCatalogue` wrapper. A written migration guide covers the breaking changes.
- MCP server included: The repository ships a `Dockerfile.mcp`, indicating a Model Context Protocol server for integrating SpotAPI into AI agent workflows.
Trade-offs
- Unofficial API contracts can break without notice: SpotAPI relies on Spotify's internal web-player endpoints, which are undocumented and subject to change. The README explicitly asks users to review the verification boundaries before integrating into production systems.
- Account operations require a session cookie: Authenticated features do not use OAuth. They require extracting a `SPOTIFY_COOKIE` from an active browser session and setting it as an environment variable, which is less portable than token-based flows.
- Playback control needs an existing device: Player commands and Studio's seek feature control an already-running Spotify device. SpotAPI does not render audio itself, so a Spotify client must be open and playing on another device or app.
- Breaking change from v1: SpotAPI 2 is an async-first rewrite with no backward compatibility. Any v1 application must follow the migration guide or pin to `spotapi==1.2.8` to continue working.
Tech stack
FAQ
No account is needed for public operations: search, artist and album lookups, credits, and public playlist reads all work anonymously. An account is needed only for liked songs, personal rankings, playlist edits, and player control, which use a session cookie set via `SPOTIFY_COOKIE`.
Spotipy wraps Spotify's official Web API, which since February 2026 requires a developer app, limits each Client ID to five authorized users in Development Mode, and requires the app owner to hold Premium. SpotAPI targets Spotify's web-player endpoints and needs no developer app or Premium account for public data.
No. SpotAPI 2 requires Python 3.11 or newer. Applications that cannot upgrade can pin `spotapi==1.2.8` to remain on the v1 release while migrating.
SpotAPI 2 is async-first, but the library ships a `SyncCatalogue` wrapper for synchronous scripts that cannot adopt `asyncio`. Full async usage through `Catalogue` or `Private` is recommended for new code.
SpotAPI uses Spotify's internal web-player endpoints, which are undocumented and can change without notice. The project maintains a set of release checks and verification boundaries, but breakage between Spotify builds is possible. The README advises reviewing those boundaries before using SpotAPI in production.