Python client for the soundvia.eu API
Project description
soundvia
Python client for the soundvia.eu API v1
Installation
pip install soundvia
git clone https://github.com/soundvia/soundvia-python
cd soundvia-python
pip install .
Usage
Get a token from your app page on soundvia.eu/developer, then pass it to the client.
from soundvia import SoundviaClient
client = SoundviaClient("YOUR_APP_TOKEN")
Status — check your app info and current rate limit config:
status = client.status()
print(status.app.name)
print(status.app.verification_status) # "pending" or "verified"
print(status.app.limits.requests_per_minute)
Search — searches across tracks, releases, artists, and playlists at once:
results = client.search("lofi beats")
for track in results.tracks:
print(track["title"])
Tracks:
page = client.list_tracks(q="chill", limit=10)
for track in page.tracks:
print(track.title, track.duration)
track = client.get_track("TRACK_ID")
print(track.stream_url)
Releases:
page = client.list_releases(q="ep", limit=5)
release = client.get_release("RELEASE_ID")
print(release.release_type) # "album", "ep", "single"
Artists:
profile = client.get_artist("rebzyyx")
print(profile.artist.display_name)
for track in profile.tracks:
print(track.title)
Playlists:
page = client.list_playlists(q="woah")
playlist = client.get_playlist("PLAYLIST_ID")
Pagination — all list_* methods take limit (default 20) and offset:
page1 = client.list_tracks(q="jazz", limit=20, offset=0)
page2 = client.list_tracks(q="jazz", limit=20, offset=20)
Context manager:
with SoundviaClient("YOUR_APP_TOKEN") as client:
print(client.status().app.name)
Client options
SoundviaClient(
token,
base_url="https://soundvia.eu/api/v1",
timeout=15, # seconds
max_retries=3, # retries on 429 and 5xx
)
On a 429, the client reads the Retry-After header and sleeps before retrying. On 5xx errors it backs off exponentially. Both give up after max_retries attempts.
Errors
from soundvia import AuthenticationError, NotFoundError, RateLimitError, APIError
try:
track = client.get_track("bad-id")
except NotFoundError:
print("track doesn't exist")
except RateLimitError as e:
print(f"retry after {e.retry_after}s")
except AuthenticationError:
print("check your token")
except APIError as e:
print(e.status_code)
All exceptions inherit from SoundviaError.
| Exception | Trigger |
|---|---|
AuthenticationError |
401 |
NotFoundError |
404 |
RateLimitError |
429 (after retries exhausted) |
APIError |
5xx or network failure |
Every response has a .raw field
If a field isn't modelled yet, the original response dict is always there:
track = client.get_track("TRACK_ID")
print(track.raw)
Tests
pip install pytest
pytest tests/
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 soundvia-1.0.0.tar.gz.
File metadata
- Download URL: soundvia-1.0.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87fd0404e6a998591d0a7aa08cfef0e7afb27197bd32522f0bb3c4f06dafd520
|
|
| MD5 |
b5377fd12c3ed87bb13f3a04f6c0a300
|
|
| BLAKE2b-256 |
5b0f3481a5c6a00ad69d7435299f635d8e0ccdd03b73e76e58e5f4c52aa711de
|
File details
Details for the file soundvia-1.0.0-py3-none-any.whl.
File metadata
- Download URL: soundvia-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdfeb7d3a667745498d3219f56617cd5a3aa1bc079b1d96ae71429253067e1d7
|
|
| MD5 |
934356d782e4bcdad058af6a22689afc
|
|
| BLAKE2b-256 |
d318028da5dd048fad792dee8cf3a6134908e0a94f1e4c38856e97acda6fe167
|