Zeus Music SDK for Python
Project description
Zeus Music SDK for Python
A fully-typed Python library for interacting with the Zeus Music Server API. This SDK makes it incredibly easy to authenticate users via OAuth 2.0 PKCE, manage tokens, and perform API calls to fetch tracks, manage user libraries, and more.
Features
- Fully typed Python client
- Support for synchronous and asynchronous HTTP requests
- Built-in OAuth 2.0 PKCE authentication flow helper
- Automatic token refreshing
- Clean, object-oriented design
Installation
pip install zeus-music-sdk
Getting Started
To use the SDK, you need a Developer API Key and a registered OAuth Client ID from the Zeus Music Developer Portal.
1. Initializing the Client
from zeus_music import ZeusClient
client = ZeusClient(
client_id="YOUR_CLIENT_ID",
api_key="YOUR_API_KEY",
redirect_uri="http://localhost:3000/callback",
scopes=["read_library", "read_profile", "write_library"],
base_url="https://api.yourzeusdomain.com" # Default is http://localhost:8000
)
2. Authenticating a User (OAuth 2.0 PKCE)
The SDK handles the complicated PKCE flow for you.
# 1. Get the authorization URL and redirect your user to it
auth_url = client.get_authorization_url()
print(f"Please go here and authorize: {auth_url}")
# 2. After the user approves, they are redirected back to your `redirect_uri` with a `code`.
# Pass the full callback URL back into the client to complete the login:
callback_url = input("Paste the full redirect URL here: ")
client.handle_callback(callback_url)
if client.is_authenticated():
print("Successfully authenticated!")
3. Using the API
Once authenticated, you can access the user's data using the .me namespace, or access public data globally.
Fetching Public Tracks
# Get a specific track by ID
track = client.tracks.get("TRACK_UUID")
# Get popular public tracks
popular_tracks = client.tracks.get_popular(limit=10)
User Library Management
# Get all saved tracks for the authenticated user
saved_tracks = client.me.library.get_saved_tracks()
# Save a new track to their library
client.me.library.save_track("TRACK_UUID")
# Remove a track from their library
client.me.library.remove_track("TRACK_UUID")
User Profile
# Get the authenticated user's profile
profile = client.me.profile.get()
print(f"Logged in as: {profile.get('email')}")
User Radio
# Generate a new radio station based on a track
station = client.me.radio.generate_station(seed_type="track", seed_id="TRACK_UUID")
# Get the next track in the radio queue
next_item = client.me.radio.get_next_queue_item(station["id"])
Advanced: Async Client
If you are building an async application (like a FastAPI backend or a Discord bot), you can use the AsyncZeusClient which has the exact same methods but uses await.
import asyncio
from zeus_music import AsyncZeusClient
async def main():
client = AsyncZeusClient(
client_id="YOUR_CLIENT_ID",
api_key="YOUR_API_KEY",
redirect_uri="http://localhost:3000/callback",
scopes=["read_library"]
)
# ... authenticate ...
tracks = await client.tracks.get_popular()
print(tracks)
asyncio.run(main())
Exceptions
The SDK throws specific exceptions for error handling:
ZeusAuthError: Raised when the OAuth flow fails, state mismatches, or tokens cannot be exchanged.ZeusAPIError: Raised when an API request fails (returns HTTP error status codes).
License
MIT License
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 zeus_music_sdk-1.0.2.tar.gz.
File metadata
- Download URL: zeus_music_sdk-1.0.2.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51dd0ed85ff488bc0b988331cb07c96a00602346612a0c8b2abbd54e4e037047
|
|
| MD5 |
ddad62fece3ff5687fb4d9e76c7f3b85
|
|
| BLAKE2b-256 |
13f091e73edfb019b89cf7ef404baaaaa1295ef659d74077ee74ecb1c048a736
|
File details
Details for the file zeus_music_sdk-1.0.2-py3-none-any.whl.
File metadata
- Download URL: zeus_music_sdk-1.0.2-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f87e70361b5d727a43f2ee74a9f851cdad1b7f8586963b6a1d3745f70b701592
|
|
| MD5 |
ffb0856379e9499efbb391a332ee5f59
|
|
| BLAKE2b-256 |
c3146c757f759ee2b9b509d9c851298e26b4d3afc8ab9c39129cca7c6f44e931
|