sonovault 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sonovault/__init__.py +7 -0
- sonovault/client.py +314 -0
- sonovault/errors.py +27 -0
- sonovault-1.0.0.dist-info/METADATA +134 -0
- sonovault-1.0.0.dist-info/RECORD +7 -0
- sonovault-1.0.0.dist-info/WHEEL +4 -0
- sonovault-1.0.0.dist-info/licenses/LICENSE +21 -0
sonovault/__init__.py
ADDED
sonovault/client.py
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"""SonoVault API client.
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
from sonovault import SonoVault
|
|
5
|
+
|
|
6
|
+
sv = SonoVault(api_key="...")
|
|
7
|
+
page = sv.tracks.search(artist="Daft Punk", title="One More Time")
|
|
8
|
+
print(page["results"][0]["isrc"])
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import time
|
|
14
|
+
from typing import Any, Dict, List, Optional, Union
|
|
15
|
+
|
|
16
|
+
import requests
|
|
17
|
+
|
|
18
|
+
from .errors import SonoVaultError
|
|
19
|
+
|
|
20
|
+
DEFAULT_BASE_URL = "https://api.sonovault.now"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class SonoVault:
|
|
24
|
+
"""Client for the SonoVault music metadata API (https://sonovault.now).
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
api_key: your API key — get a free one at https://sonovault.now
|
|
28
|
+
(1,000 requests/month, no credit card).
|
|
29
|
+
base_url: override the API base URL.
|
|
30
|
+
max_retries: retries on retryable 429/5xx responses. Default 2.
|
|
31
|
+
session: optional ``requests.Session`` (for pooling or testing).
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
api_key: str,
|
|
37
|
+
*,
|
|
38
|
+
base_url: str = DEFAULT_BASE_URL,
|
|
39
|
+
max_retries: int = 2,
|
|
40
|
+
session: Optional[requests.Session] = None,
|
|
41
|
+
):
|
|
42
|
+
if not api_key:
|
|
43
|
+
raise ValueError("SonoVault: api_key is required")
|
|
44
|
+
self._api_key = api_key
|
|
45
|
+
self._base_url = base_url.rstrip("/")
|
|
46
|
+
self._max_retries = max_retries
|
|
47
|
+
self._session = session or requests.Session()
|
|
48
|
+
|
|
49
|
+
self.tracks = _Tracks(self)
|
|
50
|
+
self.artists = _Artists(self)
|
|
51
|
+
self.labels = _Labels(self)
|
|
52
|
+
self.releases = _Releases(self)
|
|
53
|
+
self.genres = _Genres(self)
|
|
54
|
+
self.suggestions = _Suggestions(self)
|
|
55
|
+
self.streams = _Streams(self)
|
|
56
|
+
self.webhooks = _Webhooks(self)
|
|
57
|
+
|
|
58
|
+
# -- plumbing ---------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
def _request(
|
|
61
|
+
self,
|
|
62
|
+
method: str,
|
|
63
|
+
path: str,
|
|
64
|
+
*,
|
|
65
|
+
params: Optional[Dict[str, Any]] = None,
|
|
66
|
+
json: Any = None,
|
|
67
|
+
data: Optional[bytes] = None,
|
|
68
|
+
content_type: Optional[str] = None,
|
|
69
|
+
) -> Any:
|
|
70
|
+
url = self._base_url + path
|
|
71
|
+
clean_params = {k: v for k, v in (params or {}).items() if v is not None}
|
|
72
|
+
headers = {"x-api-key": self._api_key}
|
|
73
|
+
if content_type:
|
|
74
|
+
headers["Content-Type"] = content_type
|
|
75
|
+
|
|
76
|
+
last_error: Optional[SonoVaultError] = None
|
|
77
|
+
for attempt in range(self._max_retries + 1):
|
|
78
|
+
try:
|
|
79
|
+
res = self._session.request(
|
|
80
|
+
method, url, params=clean_params, json=json, data=data,
|
|
81
|
+
headers=headers, timeout=30,
|
|
82
|
+
)
|
|
83
|
+
except requests.RequestException as exc:
|
|
84
|
+
last_error = SonoVaultError(f"Network error: {exc}", 0)
|
|
85
|
+
continue
|
|
86
|
+
|
|
87
|
+
if res.ok:
|
|
88
|
+
if res.status_code == 204 or not res.content:
|
|
89
|
+
return None
|
|
90
|
+
return res.json()
|
|
91
|
+
|
|
92
|
+
try:
|
|
93
|
+
body = res.json()
|
|
94
|
+
except ValueError:
|
|
95
|
+
body = None
|
|
96
|
+
message = None
|
|
97
|
+
if isinstance(body, dict):
|
|
98
|
+
message = body.get("error") or body.get("message")
|
|
99
|
+
last_error = SonoVaultError(message or f"HTTP {res.status_code}", res.status_code, body)
|
|
100
|
+
|
|
101
|
+
# Retry only transient failures. A 429 with Retry-After is a rate
|
|
102
|
+
# limit (retryable); a 429 without one is usually quota exhaustion.
|
|
103
|
+
retry_after = res.headers.get("Retry-After")
|
|
104
|
+
retryable = res.status_code >= 500 or (res.status_code == 429 and retry_after is not None)
|
|
105
|
+
if not retryable or attempt == self._max_retries:
|
|
106
|
+
raise last_error
|
|
107
|
+
time.sleep(float(retry_after) if retry_after else 0.5 * (2 ** attempt))
|
|
108
|
+
|
|
109
|
+
raise last_error or SonoVaultError("Request failed", 0)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class _Namespace:
|
|
113
|
+
def __init__(self, client: SonoVault):
|
|
114
|
+
self._client = client
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class _Tracks(_Namespace):
|
|
118
|
+
def search(self, *, artist: str, title: str, limit: Optional[int] = None,
|
|
119
|
+
cursor: Optional[str] = None) -> Dict[str, Any]:
|
|
120
|
+
"""Search by artist + title (both required — there is no free-text query)."""
|
|
121
|
+
return self._client._request("GET", "/v1/tracks/search", params={
|
|
122
|
+
"artist": artist, "title": title, "limit": limit, "cursor": cursor,
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
def get(self, track_id: int) -> Dict[str, Any]:
|
|
126
|
+
"""Fetch a track by its SonoVault ID."""
|
|
127
|
+
return self._client._request("GET", f"/v1/tracks/{track_id}")
|
|
128
|
+
|
|
129
|
+
def by_isrc(self, isrc: str) -> Dict[str, Any]:
|
|
130
|
+
"""Look up a track by any of its ISRCs."""
|
|
131
|
+
return self._client._request("GET", f"/v1/tracks/isrc/{isrc}")
|
|
132
|
+
|
|
133
|
+
def iswc(self, *, isrc: Optional[str] = None, track_id: Optional[int] = None) -> Dict[str, Any]:
|
|
134
|
+
"""Recording → composition: the ISWC(s) behind a recording."""
|
|
135
|
+
return self._client._request("GET", "/v1/tracks/iswc",
|
|
136
|
+
params={"isrc": isrc, "id": track_id})
|
|
137
|
+
|
|
138
|
+
def by_iswc(self, iswc: str, *, limit: Optional[int] = None) -> Dict[str, Any]:
|
|
139
|
+
"""Composition → recordings: every recording of a work, by ISWC."""
|
|
140
|
+
return self._client._request("GET", f"/v1/tracks/iswc/{iswc}", params={"limit": limit})
|
|
141
|
+
|
|
142
|
+
def links(self, **ids: Union[str, int]) -> Dict[str, Any]:
|
|
143
|
+
"""Cross-platform IDs + deep links, from any platform ID or ISRC.
|
|
144
|
+
|
|
145
|
+
Keyword args: ``id``, ``isrc``, ``spotify_id``, ``beatport_id``,
|
|
146
|
+
``discogs_id``, ``musicbrainz_id``, ``applemusic_id``, ``tidal_id``,
|
|
147
|
+
``youtube_id``.
|
|
148
|
+
"""
|
|
149
|
+
return self._client._request("GET", "/v1/tracks/links", params=dict(ids))
|
|
150
|
+
|
|
151
|
+
def resolve(self, *, input_type: str,
|
|
152
|
+
items: List[Union[str, Dict[str, str]]]) -> Dict[str, Any]:
|
|
153
|
+
"""Resolve up to 100 track names, ISRCs, or platform IDs in one request."""
|
|
154
|
+
return self._client._request("POST", "/v1/tracks/resolve",
|
|
155
|
+
json={"input_type": input_type, "items": items})
|
|
156
|
+
|
|
157
|
+
def identify(self, *, fingerprint: List[int],
|
|
158
|
+
fingerprint_duration: Optional[float] = None,
|
|
159
|
+
top_n: Optional[int] = None) -> Dict[str, Any]:
|
|
160
|
+
"""Identify a track from a Chromaprint fingerprint (``fpcalc -raw``). Paid tiers."""
|
|
161
|
+
body: Dict[str, Any] = {"fingerprint": fingerprint}
|
|
162
|
+
if fingerprint_duration is not None:
|
|
163
|
+
body["fingerprint_duration"] = fingerprint_duration
|
|
164
|
+
if top_n is not None:
|
|
165
|
+
body["top_n"] = top_n
|
|
166
|
+
return self._client._request("POST", "/v1/tracks/identify", json=body)
|
|
167
|
+
|
|
168
|
+
def identify_audio(self, audio: bytes, *, length: Optional[int] = None,
|
|
169
|
+
top_n: Optional[int] = None) -> Dict[str, Any]:
|
|
170
|
+
"""Identify a track from raw audio bytes (any ffmpeg-decodable format).
|
|
171
|
+
|
|
172
|
+
Send the whole track when you can — the matching section is often
|
|
173
|
+
mid-track. Paid tiers; costs 10 + ceil(MB) credits.
|
|
174
|
+
"""
|
|
175
|
+
return self._client._request(
|
|
176
|
+
"POST", "/v1/tracks/identify",
|
|
177
|
+
params={"length": length, "top_n": top_n},
|
|
178
|
+
data=audio, content_type="application/octet-stream",
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
def browse(self, **params: Any) -> Dict[str, Any]:
|
|
182
|
+
"""Browse the catalog by ``labelId``, ``artistId``, ``genre``, ``genreId``,
|
|
183
|
+
``year``, or ``randomize``. Paid tiers."""
|
|
184
|
+
return self._client._request("GET", "/v1/tracks/browse", params=dict(params))
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class _Artists(_Namespace):
|
|
188
|
+
def search(self, *, name: str, limit: Optional[int] = None,
|
|
189
|
+
cursor: Optional[str] = None) -> Dict[str, Any]:
|
|
190
|
+
return self._client._request("GET", "/v1/artists/search",
|
|
191
|
+
params={"name": name, "limit": limit, "cursor": cursor})
|
|
192
|
+
|
|
193
|
+
def get(self, artist_id: int) -> Dict[str, Any]:
|
|
194
|
+
return self._client._request("GET", f"/v1/artists/{artist_id}")
|
|
195
|
+
|
|
196
|
+
def releases(self, artist_id: int, *, limit: Optional[int] = None,
|
|
197
|
+
cursor: Optional[str] = None) -> Dict[str, Any]:
|
|
198
|
+
return self._client._request("GET", f"/v1/artists/{artist_id}/releases",
|
|
199
|
+
params={"limit": limit, "cursor": cursor})
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class _Labels(_Namespace):
|
|
203
|
+
def search(self, *, name: str, limit: Optional[int] = None,
|
|
204
|
+
cursor: Optional[str] = None) -> Dict[str, Any]:
|
|
205
|
+
return self._client._request("GET", "/v1/labels/search",
|
|
206
|
+
params={"name": name, "limit": limit, "cursor": cursor})
|
|
207
|
+
|
|
208
|
+
def get(self, label_id: int) -> Dict[str, Any]:
|
|
209
|
+
return self._client._request("GET", f"/v1/labels/{label_id}")
|
|
210
|
+
|
|
211
|
+
def releases(self, label_id: int, *, limit: Optional[int] = None,
|
|
212
|
+
cursor: Optional[str] = None) -> Dict[str, Any]:
|
|
213
|
+
return self._client._request("GET", f"/v1/labels/{label_id}/releases",
|
|
214
|
+
params={"limit": limit, "cursor": cursor})
|
|
215
|
+
|
|
216
|
+
def artists(self, label_id: int, *, limit: Optional[int] = None,
|
|
217
|
+
cursor: Optional[str] = None) -> Dict[str, Any]:
|
|
218
|
+
return self._client._request("GET", f"/v1/labels/{label_id}/artists",
|
|
219
|
+
params={"limit": limit, "cursor": cursor})
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
class _Releases(_Namespace):
|
|
223
|
+
def search(self, *, title: str, artist: Optional[str] = None,
|
|
224
|
+
limit: Optional[int] = None, cursor: Optional[str] = None) -> Dict[str, Any]:
|
|
225
|
+
return self._client._request("GET", "/v1/releases/search", params={
|
|
226
|
+
"title": title, "artist": artist, "limit": limit, "cursor": cursor,
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
def get(self, release_id: int) -> Dict[str, Any]:
|
|
230
|
+
return self._client._request("GET", f"/v1/releases/{release_id}")
|
|
231
|
+
|
|
232
|
+
def latest(self, *, limit: Optional[int] = None,
|
|
233
|
+
cursor: Optional[str] = None) -> Dict[str, Any]:
|
|
234
|
+
"""Newly released albums (``GET /v1/releases/new``). Paid tiers."""
|
|
235
|
+
return self._client._request("GET", "/v1/releases/new",
|
|
236
|
+
params={"limit": limit, "cursor": cursor})
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
class _Genres(_Namespace):
|
|
240
|
+
def list(self) -> Dict[str, Any]:
|
|
241
|
+
"""The canonical genre/subgenre hierarchy."""
|
|
242
|
+
return self._client._request("GET", "/v1/genres")
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
class _Suggestions(_Namespace):
|
|
246
|
+
def submit(self, track_id: int, body: Dict[str, Any]) -> Dict[str, Any]:
|
|
247
|
+
"""Suggest a metadata correction for a track. Paid tiers."""
|
|
248
|
+
return self._client._request("POST", f"/v1/tracks/{track_id}/suggestions", json=body)
|
|
249
|
+
|
|
250
|
+
def list(self, *, limit: Optional[int] = None,
|
|
251
|
+
cursor: Optional[str] = None) -> Dict[str, Any]:
|
|
252
|
+
return self._client._request("GET", "/v1/suggestions",
|
|
253
|
+
params={"limit": limit, "cursor": cursor})
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
class _Streams(_Namespace):
|
|
257
|
+
def create(self, body: Dict[str, Any]) -> Dict[str, Any]:
|
|
258
|
+
"""Start monitoring an Icecast/Shoutcast stream. Paid tiers."""
|
|
259
|
+
return self._client._request("POST", "/v1/streams", json=body)
|
|
260
|
+
|
|
261
|
+
def list(self) -> Dict[str, Any]:
|
|
262
|
+
return self._client._request("GET", "/v1/streams")
|
|
263
|
+
|
|
264
|
+
def get(self, stream_id: str) -> Dict[str, Any]:
|
|
265
|
+
return self._client._request("GET", f"/v1/streams/{stream_id}")
|
|
266
|
+
|
|
267
|
+
def update(self, stream_id: str, body: Dict[str, Any]) -> Dict[str, Any]:
|
|
268
|
+
return self._client._request("PATCH", f"/v1/streams/{stream_id}", json=body)
|
|
269
|
+
|
|
270
|
+
def history(self, stream_id: str, *, since: Optional[str] = None) -> Dict[str, Any]:
|
|
271
|
+
return self._client._request("GET", f"/v1/streams/{stream_id}/history",
|
|
272
|
+
params={"since": since})
|
|
273
|
+
|
|
274
|
+
def report(self, *, from_: str, until: str,
|
|
275
|
+
stream_id: Optional[str] = None) -> Dict[str, Any]:
|
|
276
|
+
"""Play report between two timestamps. ``from_`` maps to the ``from`` param."""
|
|
277
|
+
return self._client._request("GET", "/v1/streams/report", params={
|
|
278
|
+
"from": from_, "until": until, "stream_id": stream_id,
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
def live(self) -> Dict[str, Any]:
|
|
282
|
+
"""What's playing right now across your monitored streams."""
|
|
283
|
+
return self._client._request("GET", "/v1/streams/live")
|
|
284
|
+
|
|
285
|
+
def stop(self, stream_id: str) -> None:
|
|
286
|
+
"""Stop monitoring a stream."""
|
|
287
|
+
return self._client._request("DELETE", f"/v1/streams/{stream_id}")
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class _Webhooks(_Namespace):
|
|
291
|
+
def create(self, *, url: str, event_types: Optional[List[str]] = None,
|
|
292
|
+
description: Optional[str] = None) -> Dict[str, Any]:
|
|
293
|
+
"""Register a webhook. The response includes ``secret`` once — store it."""
|
|
294
|
+
body: Dict[str, Any] = {"url": url}
|
|
295
|
+
if event_types is not None:
|
|
296
|
+
body["event_types"] = event_types
|
|
297
|
+
if description is not None:
|
|
298
|
+
body["description"] = description
|
|
299
|
+
return self._client._request("POST", "/v1/webhooks", json=body)
|
|
300
|
+
|
|
301
|
+
def list(self) -> Dict[str, Any]:
|
|
302
|
+
return self._client._request("GET", "/v1/webhooks")
|
|
303
|
+
|
|
304
|
+
def update(self, webhook_id: str, body: Dict[str, Any]) -> Dict[str, Any]:
|
|
305
|
+
return self._client._request("PATCH", f"/v1/webhooks/{webhook_id}", json=body)
|
|
306
|
+
|
|
307
|
+
def delete(self, webhook_id: str) -> None:
|
|
308
|
+
return self._client._request("DELETE", f"/v1/webhooks/{webhook_id}")
|
|
309
|
+
|
|
310
|
+
def test(self, webhook_id: str) -> Dict[str, Any]:
|
|
311
|
+
return self._client._request("POST", f"/v1/webhooks/{webhook_id}/test")
|
|
312
|
+
|
|
313
|
+
def deliveries(self, webhook_id: str) -> Dict[str, Any]:
|
|
314
|
+
return self._client._request("GET", f"/v1/webhooks/{webhook_id}/deliveries")
|
sonovault/errors.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class SonoVaultError(Exception):
|
|
2
|
+
"""Raised for any non-2xx API response.
|
|
3
|
+
|
|
4
|
+
Attributes:
|
|
5
|
+
status: HTTP status code (0 for network errors).
|
|
6
|
+
body: parsed JSON error body, when the API returned one.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
def __init__(self, message: str, status: int = 0, body=None):
|
|
10
|
+
super().__init__(message)
|
|
11
|
+
self.status = status
|
|
12
|
+
self.body = body
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def is_auth_error(self) -> bool:
|
|
16
|
+
"""Missing or invalid API key."""
|
|
17
|
+
return self.status == 401
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def is_forbidden(self) -> bool:
|
|
21
|
+
"""The endpoint needs a paid tier (or an admin key)."""
|
|
22
|
+
return self.status == 403
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def is_rate_limited(self) -> bool:
|
|
26
|
+
"""Rate limit or monthly credit quota hit."""
|
|
27
|
+
return self.status == 429
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sonovault
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python client for the SonoVault music metadata API — ISRC, ISWC, genre, labels, release dates, and cross-platform IDs for 90M+ tracks.
|
|
5
|
+
Project-URL: Homepage, https://sonovault.now
|
|
6
|
+
Project-URL: Documentation, https://sonovault.now/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/rekordcloud/sonovault-python
|
|
8
|
+
Project-URL: Issues, https://github.com/rekordcloud/sonovault-python/issues
|
|
9
|
+
Author: Rekordcloud B.V.
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: apple-music,audio-recognition,beatport,discogs,isrc,iswc,metadata,music,music-api,musicbrainz,spotify,tidal
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Requires-Dist: requests>=2.25
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# sonovault
|
|
26
|
+
|
|
27
|
+
[](https://github.com/rekordcloud/sonovault-python/actions/workflows/ci.yml)
|
|
28
|
+
[](https://pypi.org/project/sonovault/)
|
|
29
|
+
|
|
30
|
+
Python client for the **[SonoVault](https://sonovault.now)** music metadata API — 90M+ tracks with ISRC, ISWC, genre, record label, canonical release dates, and cross-platform IDs for Spotify, Apple Music, Tidal, Beatport, Discogs, and MusicBrainz, resolved in a single call.
|
|
31
|
+
|
|
32
|
+
- **One key, no OAuth** — a single `x-api-key` header, no approval queue.
|
|
33
|
+
- **Free tier** — 1,000 requests/month, no credit card: [get an API key](https://sonovault.now).
|
|
34
|
+
- **Docs** — full API reference at [sonovault.now/docs](https://sonovault.now/docs).
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install sonovault
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Python 3.9+.
|
|
43
|
+
|
|
44
|
+
## Quickstart
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from sonovault import SonoVault
|
|
48
|
+
|
|
49
|
+
sv = SonoVault(api_key="YOUR_API_KEY")
|
|
50
|
+
|
|
51
|
+
# Find a track's ISRC from artist + title
|
|
52
|
+
page = sv.tracks.search(artist="Daft Punk", title="One More Time")
|
|
53
|
+
track = page["results"][0]
|
|
54
|
+
print(track["isrc"]) # "GBDUW0000053"
|
|
55
|
+
print(track["genre"], track["releases"][0]["label"]["name"])
|
|
56
|
+
|
|
57
|
+
# Resolve that ISRC to its ID on every platform
|
|
58
|
+
links = sv.tracks.links(isrc=track["isrc"])
|
|
59
|
+
for link in links["links"]:
|
|
60
|
+
print(link["source"], link["url"]) # spotify https://open.spotify.com/track/…
|
|
61
|
+
|
|
62
|
+
# Recording → composition (ISWC), for royalty/publishing workflows
|
|
63
|
+
work = sv.tracks.iswc(isrc=track["isrc"])
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Bulk resolve
|
|
67
|
+
|
|
68
|
+
Resolve up to 100 lines — track names, ISRCs, or platform IDs — in one request (great for enriching play logs and library exports):
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
batch = sv.tracks.resolve(
|
|
72
|
+
input_type="track_name",
|
|
73
|
+
items=[
|
|
74
|
+
{"artist": "Daft Punk", "title": "Harder, Better, Faster, Stronger"},
|
|
75
|
+
{"artist": "Daft Punk", "title": "Around the World"},
|
|
76
|
+
],
|
|
77
|
+
)
|
|
78
|
+
for row in batch["results"]:
|
|
79
|
+
print(row["status"], row["track"] and row["track"]["isrc"])
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Pagination
|
|
83
|
+
|
|
84
|
+
List endpoints return `{"results": [...], "next_cursor": ...}` — pass the cursor back for the next page (`next_cursor` is `None` on the last page):
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
cursor = None
|
|
88
|
+
while True:
|
|
89
|
+
page = sv.artists.releases(42, cursor=cursor)
|
|
90
|
+
# …use page["results"]
|
|
91
|
+
cursor = page.get("next_cursor")
|
|
92
|
+
if not cursor:
|
|
93
|
+
break
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Error handling
|
|
97
|
+
|
|
98
|
+
Non-2xx responses raise `SonoVaultError`:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from sonovault import SonoVaultError
|
|
102
|
+
|
|
103
|
+
try:
|
|
104
|
+
sv.tracks.browse(genre="House") # paid-tier endpoint
|
|
105
|
+
except SonoVaultError as err:
|
|
106
|
+
print(err.status, err.is_forbidden, err)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Rate-limited responses that carry a `Retry-After` header are retried automatically (twice by default; configure with `max_retries`).
|
|
110
|
+
|
|
111
|
+
## API coverage
|
|
112
|
+
|
|
113
|
+
| Namespace | Methods |
|
|
114
|
+
|---|---|
|
|
115
|
+
| `sv.tracks` | `search`, `get`, `by_isrc`, `iswc`, `by_iswc`, `links`, `resolve`, `identify`, `identify_audio`, `browse` |
|
|
116
|
+
| `sv.artists` | `search`, `get`, `releases` |
|
|
117
|
+
| `sv.labels` | `search`, `get`, `releases`, `artists` |
|
|
118
|
+
| `sv.releases` | `search`, `get`, `latest` |
|
|
119
|
+
| `sv.genres` | `list` |
|
|
120
|
+
| `sv.suggestions` | `submit`, `list` |
|
|
121
|
+
| `sv.streams` | `create`, `list`, `get`, `update`, `history`, `report`, `live`, `stop` |
|
|
122
|
+
| `sv.webhooks` | `create`, `list`, `update`, `delete`, `test`, `deliveries` |
|
|
123
|
+
|
|
124
|
+
Some endpoints (audio identify, browse, charts, stream monitoring) need a paid tier — see [pricing](https://sonovault.now/pricing). Everything else works on the free tier.
|
|
125
|
+
|
|
126
|
+
## Related
|
|
127
|
+
|
|
128
|
+
- [SonoVault API docs](https://sonovault.now/docs) — full endpoint reference with examples in 8 languages
|
|
129
|
+
- [sonovault-js](https://github.com/rekordcloud/sonovault-js) — the TypeScript/Node client
|
|
130
|
+
- [Free ISRC lookup](https://sonovault.now/isrc-lookup) · [ISWC lookup](https://sonovault.now/iswc-lookup) — browser tools built on the same API
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
sonovault/__init__.py,sha256=DhG_Yije4saOdfP5RiM4u4xx0vG0ea8_M1UXv_4B-U4,214
|
|
2
|
+
sonovault/client.py,sha256=cF86-w6H-8lWvIbcZtS87x-I5Ih1RsPOaNS6hWb48gM,13424
|
|
3
|
+
sonovault/errors.py,sha256=Qm_ThqzT3wvKW4Mj_kO0oUcnDDjMHp-6ygHOCGUECto,798
|
|
4
|
+
sonovault-1.0.0.dist-info/METADATA,sha256=q13e1ynBRD0RM0NMVLMd1BKYp1dRcGCUC8rxU_EdoBY,4964
|
|
5
|
+
sonovault-1.0.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
6
|
+
sonovault-1.0.0.dist-info/licenses/LICENSE,sha256=t3zvEZpn3Mg2Txx7h2rsyGwZBlzpntW1CkBxFl0T8qw,1073
|
|
7
|
+
sonovault-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rekordcloud B.V.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|