Clients
The SDK exposes two entry points that share the same configuration:
SpotifyClient for sync workflows and AsyncSpotifyClient for async
workflows.
Construction
Both clients accept the same constructor arguments.
| Parameter | Type | Default | Description |
|---|---|---|---|
access_token |
str |
optional | Spotify access token (mutually exclusive with other auth inputs) |
client_id |
str |
optional | Spotify client ID (client credentials flow) |
client_secret |
str |
optional | Spotify client secret (client credentials flow) |
auth_provider |
AuthProvider |
optional | Custom auth provider (mutually exclusive with other auth inputs) |
timeout |
float |
30.0 |
Request timeout in seconds |
max_retries |
int |
3 |
Maximum retries for transient errors |
Client Credentials
Use client credentials to let the SDK obtain and refresh tokens automatically.
Custom Auth Provider
Pass a custom auth provider instance for advanced or future flows.
Environment Variables
If client_id or client_secret are omitted, the SDK reads:
SPOTIFY_SDK_CLIENT_IDSPOTIFY_SDK_CLIENT_SECRET
Explicit arguments override environment variables.
Lifecycle
Use context managers to ensure connections are closed. You can also call
close()/await close() directly.
Available services
The main client exposes service objects as attributes:
| Attribute | Description |
|---|---|
client.albums |
Album operations |
client.artists |
Artist operations |
client.playlists |
Playlist operations |
client.tracks |
Track operations |
See the full service reference for method-level details.