Registry / http-networking / spotipy2

spotipy2

JSON →
library0.6.1pypypi✓ verified 84d ago

The next generation Spotify Web API wrapper for Python. Current version 0.6.1, supports Python 3.7+. Active development with async support, dataclass types, and OAuth flows.

pip install spotipy2
INSTALL
IMPORT
SIG · SPOTIPY2
S
spotipy2
http-networkingpythonv0.6.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Spotify
from spotipy2 import Spotify
from spotipy2.client import Spotify
Spotify is exported from the top-level package, not client module.
ClientCredentialsFlow
from spotipy2.auth import ClientCredentialsFlow
from spotipy2 import ClientCredentialsFlow
Authentication classes are in spotipy2.auth module.
Track
from spotipy2.types import Track
from spotipy2 import Track
Types are in spotipy2.types, not top-level.

Authenticate using Client Credentials Flow and fetch a track.

import os from spotipy2 import Spotify from spotipy2.auth import ClientCredentialsFlow client_id = os.environ.get('SPOTIFY_CLIENT_ID', '') client_secret = os.environ.get('SPOTIFY_CLIENT_SECRET', '') auth = ClientCredentialsFlow(client_id=client_id, client_secret=client_secret) client = Spotify(auth) track = client.get_track('4cOdK2wGLETKBW3PvgPWqT') print(track.name)
Debug
Known issues
gotchaIn v0.6 simplified types were removed; all types now have optional fields defaulting to None.
fix
Check for None on fields like track.album when accessing nested data.
affects: >=0.6
breakingIn v0.3 Type.from_dict became synchronous. Async code expecting await will break.
fix
Remove await when calling Type.from_dict; it now returns directly.
affects: >=0.3
gotchaCaching with MongoDB is only available if MongoDB is installed and configured; it's not built-in.
fix
Ensure pymongo is installed and a MongoDB instance is running. Pass cache=... to Spotify constructor.
affects: >=0.5
Errors
Common errors & fixes
ImportError: cannot import name 'Spotify' from 'spotipy2.client'
Incorrect import path for Spotify client.
fix
Use: from spotipy2 import Spotify
TypeError: Object of type Track is not JSON serializable
Trying to json.dumps a spotipy2 type directly.
fix
Use dataclasses.asdict(track) or access track.__dict__ before serializing.
spotipy2.exceptions.SpotifyException: 401 - Unauthorized
Invalid or missing credentials.
fix
Check that SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET environment variables are set correctly.
Upgrade
Version history
0.6.1latest on PyPI · released Dec 30, 2022
Audit
Dependencies
httpxrequiredHTTP client for async requests
pydanticrequiredData validation and settings
Agent activity
33 hits · last 30 days
node
28
OpenAI (training)
2
Resources
spotipy2 — pip install spotipy2 · libregistry