Registry / http-networking / spotify-uri

spotify-uri

JSON →
library1.0.3pypypi✓ verified 84d ago

A Python port of @TooTallNate/spotify-uri for parsing and formatting Spotify URIs and URLs. Current version 1.0.3, actively maintained with low release cadence.

pip install spotify-uri
INSTALL
IMPORT
SIG · SPOTIFY-URI
S
spotify-uri
http-networkingpythonv1.0.3
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.

parse
from spotify_uri import parse
import spotify_uri; spotify_uri.parse()
The recommended import is from spotify_uri import parse
SpotifyUri
from spotify_uri import SpotifyUri

Parse Spotify URIs and URLs to extract type and ID.

from spotify_uri import parse uri = parse('spotify:track:4iV5W9uYEdYUVa79Axb7Rh') print(uri.type) # track print(uri.id) # 4iV5W9uYEdYUVa79Axb7Rh url = parse('https://open.spotify.com/track/4iV5W9uYEdYUVa79Axb7Rh') print(url.type) # track print(url.id) # 4iV5W9uYEdYUVa79Axb7Rh
Debug
Known issues
gotchaThe parse function returns a SpotifyUri object. Accessing attributes before confirming type may raise AttributeError for incompatible types.
fix
Check uri.type first, or use hasattr before accessing type-specific attributes.
affects: all
deprecatedSome older examples show using 'spotify_uri.uri.SpotifyUri' or 'spotify_uri.spotify_uri.SpotifyUri'. These are internal paths and may change.
fix
Use from spotify_uri import SpotifyUri or from spotify_uri import parse.
affects: <=1.0.2
Errors
Common errors & fixes
AttributeError: 'SpotifyUri' object has no attribute 'id'
Parsed a URI that does not have an 'id' attribute (e.g., a playlist URI with only owner). Check type first.
fix
if uri.type == 'track': print(uri.id) else: handle other types.
spotify_uri.uri.SpotifyUri
Incorrect import path; the correct module is spotify_uri.
fix
Use 'from spotify_uri import SpotifyUri' or 'from spotify_uri import parse'.
Upgrade
Version history
1.0.3latest on PyPI · released Jun 21, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
spotify-uri — pip install spotify-uri · libregistry