Python SDK
Install and start using the Python SDK.
Intro
The Spotify Web API with fixes and improvements from sonallux SDK provides access to the Spotify Web API with fixes and improvements from sonallux REST APIs.
You can use Spotify's Web API to discover music and podcasts, manage your Spotify library, control audio playback, and much more. Browse our available Web API endpoints using the sidebar at left, or via the navigation bar on top of this page on smaller screens.
In order to make successful Web API requests your app will need a valid access token. One can be obtained through OAuth 2.0.
The base URI for all Web API requests is https://api.spotify.com/v1.
Need help? See our Web API for more information, or visit the Spotify for Developers community forum to ask questions and connect with other developers.
Installation
Add the SDK to your project from its folder, with whichever package manager your project uses. Give each tool a path containing a slash, such as ../spotify-web-api-with-fixes-and-improvements-from-sonallux — a bare folder name is looked up on PyPI instead, and resolves to whatever project holds that name there:
pip install <path-to-sdk>uv add <path-to-sdk>poetry add <path-to-sdk>Quick Start
Synchronous client
Construct SpotifyWebApiWithFixesAndImprovementsFromSonalluxClient with keyword arguments, and call close() when you are done. Every argument is optional.
from spotify_web_api_with_fixes_and_improvements_from_sonallux import (
SpotifyWebApiWithFixesAndImprovementsFromSonalluxClient,
)
from spotify_web_api_with_fixes_and_improvements_from_sonallux.auth import Oauth20Scope
from spotify_web_api_with_fixes_and_improvements_from_sonallux.core import AuthorizationCodeCredentials
def prompt(url: str) -> str:
return input(f"Open {url}, then paste the code: ")
client = SpotifyWebApiWithFixesAndImprovementsFromSonalluxClient(
oauth_2_0=AuthorizationCodeCredentials[Oauth20Scope](
client_id="YOUR_CLIENT_ID", redirect_uri="YOUR_REDIRECT_URI", prompt_for_authorization_code=prompt
),
)
client.close()Alternatively, scope it — with SpotifyWebApiWithFixesAndImprovementsFromSonalluxClient(...) as client: closes the pool on exit.
Asynchronous client
AsyncSpotifyWebApiWithFixesAndImprovementsFromSonalluxClient mirrors SpotifyWebApiWithFixesAndImprovementsFromSonalluxClient with identical method names, and every endpoint method is a coroutine. It takes the same arguments, with some differences — for example, the transport argument is custom_async_http_client.
from asyncio import run, to_thread
from spotify_web_api_with_fixes_and_improvements_from_sonallux import (
AsyncSpotifyWebApiWithFixesAndImprovementsFromSonalluxClient,
)
from spotify_web_api_with_fixes_and_improvements_from_sonallux.auth import Oauth20Scope
from spotify_web_api_with_fixes_and_improvements_from_sonallux.core import AsyncAuthorizationCodeCredentials
async def prompt(url: str) -> str:
print(f"Open {url}")
return await to_thread(input, "Paste the code: ")
async def main() -> None:
client = AsyncSpotifyWebApiWithFixesAndImprovementsFromSonalluxClient(
oauth_2_0=AsyncAuthorizationCodeCredentials[Oauth20Scope](
client_id="YOUR_CLIENT_ID", redirect_uri="YOUR_REDIRECT_URI", prompt_for_authorization_code=prompt
),
)
await client.aclose()
run(main())Alternatively, scope it — async with AsyncSpotifyWebApiWithFixesAndImprovementsFromSonalluxClient(...) as client: closes the pool on exit.

