Skip to content

Spotify SDK for Python

Spotify SDK logo

PyPI version Python versions Actions status License

spotify-sdk is a Python client for the Spotify Web API. It provides sync and async interfaces with type-safe responses, so you can build apps against Spotify without managing raw HTTP or JSON.

Community Project

This is an independent, community-developed library and is not affiliated with or endorsed by Spotify.

Quickstart Installation API Reference View on GitHub


Features

  • Type-safe models: Pydantic models with full type hints for every response
  • Sync and async clients: SpotifyClient and AsyncSpotifyClient with identical APIs
  • Automatic retries: Exponential backoff with jitter for rate limits, server errors, and timeouts
  • Auth helpers: Client credentials, authorization code, and local browser-based flows
  • Token caching: Built-in in-memory cache with a pluggable TokenCache interface
  • Context managers: with and async with support for clean resource cleanup

Start in 60 Seconds

from spotify_sdk import SpotifyClient

with SpotifyClient(access_token="your-access-token") as client:
    album = client.albums.get("<spotify-album-id>")
    print(album.name)
    print(album.artists[0].name)
import asyncio
from spotify_sdk import AsyncSpotifyClient


async def main() -> None:
    async with AsyncSpotifyClient(access_token="your-access-token") as client:
        album = await client.albums.get("<spotify-album-id>")
        print(album.name)
        print(album.artists[0].name)


asyncio.run(main())

See the full quickstart


  • Quickstart


    Install, configure auth, and make your first API call in minutes.

    Start here

  • Authentication


    Client credentials, authorization code, auth.authorize_local(), and pluggable token caching.

    Auth guide

  • Services


    Albums, Artists, Audiobooks, Chapters, Episodes, Library, Playlists, Search, Shows, Tracks, and Users.

    Service reference

  • Installation


    Install with uv or pip and verify your setup. Requires Python 3.10+.

    Install

  • Error Handling


    Handle RateLimitError, AuthenticationError, and other SDK exceptions.

    Exceptions

  • Clients & Models


    Full reference for client configuration and Pydantic response models.

    Explore reference