Typed Python SDK for the CheckLeaked Spotify Data API and RapidAPI spotify81.
Project description
checkleaked-spotify-api
Typed Python SDK for the Spotify Data API, covering the same 110 methods
and 25 namespaces as
@checkleaked/spotify-api.
It works with both the
RapidAPI spotify81 API
and the direct
CheckLeaked proxy.
This is a data API client. It does not require Spotify OAuth credentials.
Install
pip install checkleaked-spotify-api
Quick start
from spotify_api_sdk import SpotifyApiClient
spotify = SpotifyApiClient(api_key="your-rapidapi-key")
results = spotify.search.search(
"daft punk",
type="artists",
limit=5,
)
artist = spotify.artists.overview(
"spotify:artist:4tZwfgrHOc3mvqYlEYSvVi"
)
lyrics = spotify.tracks.lyrics(
"https://open.spotify.com/track/0DiWol3AO6WpXZgp0goxAV",
format="lrc",
)
Methods return the API's unwrapped data payload. Use
client.request_raw(...) when you need the complete success envelope.
Providers
RapidAPI is the default and automatically adds
x-rapidapi-host: spotify81.p.rapidapi.com:
spotify = SpotifyApiClient(
api_key="your-rapidapi-key",
provider="rapidapi",
)
The direct proxy exposes the same methods and paths. Use a key issued by the direct portal:
spotify = SpotifyApiClient(
api_key="your-direct-proxy-key",
provider="proxy",
)
The API key may be omitted when SPOTIFY_API_KEY or RAPIDAPI_KEY is set.
Pythonic and npm-compatible names
Python methods use snake_case, while npm-style camelCase aliases are also
available:
spotify.artists.top_tracks(id, market="US")
spotify.artists.topTracks(id, market="US") # exact npm-style alias
Every method supports per-call request_timeout, request_retries,
request_headers, and an additional extra_query mapping. POST methods also
accept a free-form body mapping.
IDs, URIs, and URLs
Spotify IDs may be supplied as bare IDs, Spotify URIs, or open.spotify.com URLs. Multi-ID methods accept comma-separated strings or Python sequences.
from spotify_api_sdk import normalize_id, normalize_ids
normalize_id("spotify:track:0DiWol3AO6WpXZgp0goxAV")
normalize_ids([
"spotify:artist:4tZwfgrHOc3mvqYlEYSvVi",
"https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02",
])
Pagination
from spotify_api_sdk import collect
items = collect(
lambda **page: spotify.artists.albums(id=artist_id, **page),
get_items=lambda response: (
response.get("data", {})
.get("artist", {})
.get("discography", {})
.get("albums", {})
.get("items", [])
),
limit=50,
max_items=500,
)
Errors
from spotify_api_sdk import (
AuthError,
HttpError,
RateLimitError,
SpotifyApiError,
TimeoutError,
)
try:
spotify.search.search("daft punk")
except RateLimitError as error:
print(error.retry_after_ms)
except AuthError:
print("Invalid or unsubscribed API key")
except SpotifyApiError as error:
print(error.status, error.code, error.url)
Configuration
spotify = SpotifyApiClient(
api_key="...",
provider="rapidapi", # rapidapi (default) | proxy
timeout=30,
retries=2,
retry_delay=0.5,
headers={"x-my-header": "value"},
debug=True,
on_request=lambda info: print("request", info["url"]),
on_response=lambda info: print("response", info["status"]),
on_retry=lambda info: print("retry", info["attempt"]),
)
The client is also a context manager:
with SpotifyApiClient(api_key="...") as spotify:
markets = spotify.markets.get()
See API_REFERENCE.md for every namespace and method.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file checkleaked_spotify_api-1.0.0.tar.gz.
File metadata
- Download URL: checkleaked_spotify_api-1.0.0.tar.gz
- Upload date:
- Size: 27.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c1d02d74ade0c87cacdfe6ad95681333154768fb1fb3a02d423dfe7c7db1b26
|
|
| MD5 |
7c4a4b58c5c12dd98df1c4e145c8f8aa
|
|
| BLAKE2b-256 |
8f901e3eca2b72fc131bdbb11eef845b4b7a1c698040b30cba603707e29142ae
|
Provenance
The following attestation bundles were made for checkleaked_spotify_api-1.0.0.tar.gz:
Publisher:
publish.yml on eduair94/checkleaked-spotify-api-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
checkleaked_spotify_api-1.0.0.tar.gz -
Subject digest:
8c1d02d74ade0c87cacdfe6ad95681333154768fb1fb3a02d423dfe7c7db1b26 - Sigstore transparency entry: 2256600518
- Sigstore integration time:
-
Permalink:
eduair94/checkleaked-spotify-api-python@80012dd4e270ccf4afd07c5109ce0a7cca41732a -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/eduair94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@80012dd4e270ccf4afd07c5109ce0a7cca41732a -
Trigger Event:
release
-
Statement type:
File details
Details for the file checkleaked_spotify_api-1.0.0-py3-none-any.whl.
File metadata
- Download URL: checkleaked_spotify_api-1.0.0-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b30b3778778baa9cdf4818a84cd4ccd3e0d6f76cba90401e8fb372df2a6bfe7a
|
|
| MD5 |
e4fd835acc44b2832c36af3dd3548114
|
|
| BLAKE2b-256 |
43a52e4db7e89da9cffeecb9fcd7580c8338605908e2467fd375a3a955ebdc3e
|
Provenance
The following attestation bundles were made for checkleaked_spotify_api-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on eduair94/checkleaked-spotify-api-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
checkleaked_spotify_api-1.0.0-py3-none-any.whl -
Subject digest:
b30b3778778baa9cdf4818a84cd4ccd3e0d6f76cba90401e8fb372df2a6bfe7a - Sigstore transparency entry: 2256600526
- Sigstore integration time:
-
Permalink:
eduair94/checkleaked-spotify-api-python@80012dd4e270ccf4afd07c5109ce0a7cca41732a -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/eduair94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@80012dd4e270ccf4afd07c5109ce0a7cca41732a -
Trigger Event:
release
-
Statement type: