Official Python SDK for the AudD music recognition API.
Project description
audd
Official Python SDK for the AudD music recognition API.
Quickstart
pip install audd
from audd import AudD
audd = AudD(api_token="test") # use your token from https://dashboard.audd.io
result = audd.recognize("https://audd.tech/example.mp3")
if result:
print(f"{result.artist} — {result.title}")
Capabilities
| What | How |
|---|---|
| Recognize a short clip (≤25s) | audd.recognize(source) |
| Recognize a long file (hours, days) | audd.recognize_enterprise(source, limit=...) |
| Manage stream recognition (set callback, longpoll for events) | audd.streams.* |
source accepts a URL, a file path, a file-like object, or raw bytes — auto-detected.
Async
Use AsyncAudD instead — same surface:
from audd import AsyncAudD
async def main():
audd = AsyncAudD(api_token="test")
try:
result = await audd.recognize("https://audd.tech/example.mp3")
print(result)
finally:
await audd.aclose()
Errors
Every server error becomes a typed exception:
from audd import AudD, AudDAuthenticationError, AudDSubscriptionError
try:
AudD(api_token="bad").recognize("https://x.mp3")
except AudDAuthenticationError as e:
print(f"check your token: {e.error_code} {e.message}")
except AudDSubscriptionError:
print("this endpoint isn't enabled on your token")
The full hierarchy is documented in src/audd/errors.py. Every AudDAPIError carries error_code, message, http_status, request_id, requested_params, request_method, branded_message, and raw_response.
Forward compatibility
Models accept and round-trip unknown server fields via model_extra:
result = audd.recognize("https://example.mp3", return_=["apple_music"])
print(result.apple_music.url) # typed
print(result.model_extra) # any other unknown fields
If AudD adds a new metadata block tomorrow (e.g., tidal), you can read it as result.model_extra["tidal"] today — no SDK release needed. The next SDK release adds the typed tidal field, and both paths keep working.
Streams
Manage real-time stream recognition (set callback, longpoll for events):
audd.streams.set_callback_url("https://your.server/cb")
audd.streams.add("https://your.stream.url", radio_id=42)
for event in audd.streams.list():
print(event)
Receiving events without exposing your token
For browser widgets and other contexts where shipping the api_token would leak it,
derive a category server-side and share that with the consumer:
from audd import LongpollConsumer
# `category` is derived server-side via AudD(...).streams.derive_longpoll_category(radio_id),
# then shared with the browser/widget. The consumer carries no api_token.
consumer = LongpollConsumer(category="abc123def")
for event in consumer.iterate(timeout=30):
print(event)
Configuration
import httpx
from audd import AudD
audd = AudD(
api_token="...",
max_retries=3, # retry budget per call
backoff_factor=0.5, # initial backoff seconds (jittered)
httpx_client=httpx.Client(proxies="http://corp-proxy:8080"),
)
Default timeouts: 30s connect / 60s read for standard endpoints, 30s connect / 1 hour read for the enterprise endpoint. Pass timeout= per call to override.
Concurrency: AudD and AsyncAudD are safe for concurrent use — share one instance across threads or asyncio tasks. set_api_token(...) rotates the token safely; in-flight requests continue with the old token, subsequent requests use the new one.
Custom catalog (advanced — not for music recognition)
⚠ The custom-catalog endpoint is NOT how you submit audio for music recognition. For recognition, use
recognize()orrecognize_enterprise(). The custom-catalog endpoint adds songs to your private fingerprint database for your account. Requires special access — contact api@audd.io if you need it.
audd.custom_catalog.add(audio_id=42, source="https://my.song.mp3")
Advanced
For endpoints not yet wrapped by typed methods on this SDK, use the raw-request escape hatch:
raw = audd.advanced.raw_request("someNewMethod", {"q": "x"})
Spec contract
This SDK builds against the audd-openapi spec. The contract tests in tests/contract/ validate the parser against the canonical fixture set on every push, on a daily cron, and on every spec update.
License
MIT — see LICENSE.
Support
- Documentation: https://docs.audd.io
- Tokens: https://dashboard.audd.io
- Email: api@audd.io
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 audd-1.4.1.tar.gz.
File metadata
- Download URL: audd-1.4.1.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64c91a4ad2b95a5b44880a970cb727624937bbf28d9e79f498d9b2da752659de
|
|
| MD5 |
82dd85d714719ec5fb0d26093aa6f50a
|
|
| BLAKE2b-256 |
bb583ed8d5ae45f9a11be3709605371c2fe22ff9af7394b946d5b3eb26bfb27d
|
Provenance
The following attestation bundles were made for audd-1.4.1.tar.gz:
Publisher:
release.yml on AudDMusic/audd-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
audd-1.4.1.tar.gz -
Subject digest:
64c91a4ad2b95a5b44880a970cb727624937bbf28d9e79f498d9b2da752659de - Sigstore transparency entry: 1444142192
- Sigstore integration time:
-
Permalink:
AudDMusic/audd-python@e48f8382e62cc1dda2b3096336b7ec6fb7b53561 -
Branch / Tag:
refs/tags/v1.4.1 - Owner: https://github.com/AudDMusic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e48f8382e62cc1dda2b3096336b7ec6fb7b53561 -
Trigger Event:
push
-
Statement type:
File details
Details for the file audd-1.4.1-py3-none-any.whl.
File metadata
- Download URL: audd-1.4.1-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a10dff0d50949db44d4d5fe4ab0519f6d0230c4ac7e1bf2211045cd6a20914d4
|
|
| MD5 |
659d3041b63959030d546d0fc9f86a10
|
|
| BLAKE2b-256 |
5ab76cb32dc8e648f1cd3ba09edada55b6764366bac07492374f30907d5ab487
|
Provenance
The following attestation bundles were made for audd-1.4.1-py3-none-any.whl:
Publisher:
release.yml on AudDMusic/audd-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
audd-1.4.1-py3-none-any.whl -
Subject digest:
a10dff0d50949db44d4d5fe4ab0519f6d0230c4ac7e1bf2211045cd6a20914d4 - Sigstore transparency entry: 1444142427
- Sigstore integration time:
-
Permalink:
AudDMusic/audd-python@e48f8382e62cc1dda2b3096336b7ec6fb7b53561 -
Branch / Tag:
refs/tags/v1.4.1 - Owner: https://github.com/AudDMusic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e48f8382e62cc1dda2b3096336b7ec6fb7b53561 -
Trigger Event:
push
-
Statement type: