Skip to main content

Unofficial and open source Python library for interacting with the AudioSalad API

Project description

mtl-audiosalad-sdk

Unofficial, experimental Python SDK for interacting with AudioSalad APIs.

It provides three layers:

  • services/audiosalad_client.py — low-level HTTP client for AudioSalad client API
  • services/audiosalad_api.py — higher-level service wrapper with safe defaults and logging
  • services/audiosalad_web.py — web layer for endpoints that require browser-like headers/cookies

Status

  • Experimental and subject to change
  • Not affiliated with AudioSalad

Installation

Prerequisites

  • Python 3.12+
  • Poetry (or use your preferred tooling)

Install

git clone https://github.com/musictechlab/mtl-audiosalad-sdk.git
cd mtl-audiosalad-sdk
poetry install

Configuration

Set the following environment variables (recommended):

  • AUDIOSALAD_ACCESS_ID — your AudioSalad access ID
  • AUDIOSALAD_REFRESH_TOKEN — your AudioSalad refresh token
  • AUDIOSALAD_API_URL — base URL (defaults to https://<client-namespace>.dashboard.audiosalad.com)
  • AUDIOSALAD_TOKEN_FILE — path to persist tokens (defaults to /tmp/audiosalad_tokens.json)

Example:

export AUDIOSALAD_ACCESS_ID=xxx
export AUDIOSALAD_REFRESH_TOKEN=yyy
# optional overrides
export AUDIOSALAD_API_URL=https://<client-namespace>.dashboard.audiosalad.com
export AUDIOSALAD_TOKEN_FILE=/tmp/audiosalad_tokens.json

Quickstart

Low-level client (AudioSaladClient)

from services.audiosalad_client import AudioSaladClient

client = AudioSaladClient(
    # If omitted, values are read from environment variables
    access_id="your_access_id",
    refresh_token="your_refresh_token",
    # base_url is optional; defaults to AUDIOSALAD_API_URL
)

# Releases
releases = client.get_releases(params={"page": 1, "page_length": 25})
release = client.get_release("release_id")

# Tracks
tracks = client.get_tracks(params={"page": 1})
track = client.get_track("track_id")

# Artists
artists = client.get_artists(params={"page": 1})
artist = client.get_artist("artist_id")

# Labels
labels = client.get_labels(params={"page": 1})
label_by_id = client.get_label(label_id=123)
label_by_name = client.get_label(label_name="My Label")

# Reports
sales = client.get_sales_report(start_date="2025-01-01", end_date="2025-01-31")
earnings = client.get_earnings_report(start_date="2025-01-01", end_date="2025-01-31")

# Ingestion (Dashboard/analytics endpoints)
ingestion = client.run_ingestion(
    label_id="123",
    s3_bucket="example-bucket.s3.us-east-1.amazonaws.com",
    s3_id="AWS_ACCESS_ID",
    s3_key="AWS_SECRET_KEY",
    s3_path="optional/prefix",
    wav_ready=10,
)
status = client.get_ingestion_status(ingest_id=ingestion.get("ingest_id", 0))

# Delivery
delivery = client.schedule_delivery(
    release_ids=["r1", "r2"],
    target_ids=["t1"],
    run_date="2025-01-31T10:00:00Z",
    action="full-update",
)
targets = client.list_delivery_targets()
delivery_status = client.get_delivery_status(release_ids=["r1"]) 

High-level service (AudioSaladAPI)

from services.audiosalad_api import AudioSaladAPI

service = AudioSaladAPI(
    access_id="your_access_id",
    refresh_token="your_refresh_token",
)

all_releases = service.get_all_releases(params={"page": 1})
release = service.get_release_by_id("release_id")

all_tracks = service.get_all_tracks(params={"page": 1})
track = service.get_track_by_id("track_id")

all_artists = service.get_all_artists(params={"page": 1})
artist = service.get_artist_by_id("artist_id")

all_labels = service.get_all_labels()
label = service.get_label_by_id(label_id=123)
label2 = service.get_label_by_name("My Label")

sales = service.get_sales_report_for_period()
earnings = service.get_earnings_report_for_period()

# Ingestion helpers
ing = service.run_ingestion(
    label_id="123",
    s3_bucket="example-bucket.s3.us-east-1.amazonaws.com",
    s3_id="AWS_ACCESS_ID",
    s3_key="AWS_SECRET_KEY",
)
ing_status = service.get_ingestion_status(ingest_id=ing.get("ingest_id", 0))

# Delivery helpers
targets = service.list_delivery_targets()
delivery = service.schedule_delivery(["r1"], ["t1"], "2025-01-31T10:00:00Z", "meta-update")
status = service.get_delivery_status(release_ids=["r1"]) 

Web endpoints (AudioSaladWebService)

Some endpoints in the AudioSalad web app require browser-like headers and a valid x-auth-token. This helper wraps those flows.

from services.audiosalad_web import AudioSaladWebService

web = AudioSaladWebService(auth_token="your_x_auth_token")

# Artists (auto-paginated)
artists = web.get_artists(page=1, page_length=50)

# Labels (single payload; API returns all labels)
labels = web.get_labels()

# Genres
genres = web.get_genres()
genre = web.get_genre("genre_id")

How to obtain x-auth-token:

  1. Log in to the AudioSalad web interface: https://<client-namespace>.audiosalad.com
  2. Open browser developer tools
  3. Go to the Network tab, select any API request
  4. Copy the x-auth-token header value
  5. Use it to initialize AudioSaladWebService

Optionally, pass cookie_token if required by your environment.

Examples

See services/ for available methods. You can adapt the snippets above into runnable scripts.

Tests

poetry run pytest

Code quality

poetry run black .
poetry run autopep8 --in-place --recursive .
poetry run flake8

Contributing

  1. Fork the repository
  2. Create a new branch (git checkout -b feat/xyz)
  3. Make your changes
  4. Ensure tests pass
  5. Open a Pull Request

License

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


MusicTechLab — Digital Commerce Solutions for the Music Industry

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

audiosalad_python_sdk-0.0.1.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

audiosalad_python_sdk-0.0.1-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file audiosalad_python_sdk-0.0.1.tar.gz.

File metadata

  • Download URL: audiosalad_python_sdk-0.0.1.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.18 Darwin/23.6.0

File hashes

Hashes for audiosalad_python_sdk-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7eea06dad307469d7311ae8c1e41a2d1ce8d5b5bf705d9494564ea82f136036c
MD5 236f40720314cbe7f13ed18f1fb2de5f
BLAKE2b-256 8414a77c451ca0c4b73da99118d9f8d4da316f000ecfe03efb47546d1f8b0ff5

See more details on using hashes here.

File details

Details for the file audiosalad_python_sdk-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for audiosalad_python_sdk-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2bf2a6ee574c3a298ef9608a701ec13f0acff58e9cac91275c845307be942a73
MD5 fca87ff37274561778fe296fccdb0306
BLAKE2b-256 1e9feaea45714d1ffd2044a0d64c28271077e3e3d27cecf3ef5d750319f6178d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page