audd
Official Rust SDK for the AudD music recognition API. Async only — built on tokio + reqwest.
Quickstart
[]
= "1.4"
= { = "1", = ["rt-multi-thread", "macros"] }
use AudD;
async
cargo run --example recognize_url reproduces the hello-world end-to-end against the live API.
Capabilities
| What | How |
|---|---|
| Recognize a short clip (≤25s) | audd.recognize(source).await? |
| Recognize a long file (hours, days) | audd.recognize_enterprise(source, opts).await? |
| Manage real-time stream recognition | audd.streams().add(url, radio_id, None).await? etc. |
source accepts &str (URL or path), PathBuf, Vec<u8>, or any Source variant — auto-detected via Into<Source>.
Source variants
use ;
use PathBuf;
# async
Errors
Every server error becomes a typed [AudDError] variant. Use the helper predicates rather than matching on numeric codes:
use ;
# async
The helpers are: is_authentication, is_quota, is_subscription, is_custom_catalog_access, is_invalid_request, is_invalid_audio, is_rate_limit, is_stream_limit, is_not_released, is_blocked, is_needs_update, is_api. Every AudDError::Api variant carries code, message, kind, http_status, request_id, requested_params, request_method, branded_message, and raw_response.
Forward compatibility
Models accept and round-trip unknown server fields via extras:
# use AudD;
# async
If AudD adds a new metadata block tomorrow, you can read it as result.extras["tidal"] today — no SDK release needed.
Every public model derives Serialize + Deserialize, so you can round-trip recognition results into your own logs / queues / databases:
# use RecognitionResult;
#
Configuration
use AudD;
let client = builder
.proxy
.build.unwrap;
let audd = builder
.max_attempts // retry budget per call (default 3)
.backoff_factor // initial backoff seconds, jittered (default 0.5)
.reqwest_client // inject a configured client (proxy, mTLS, etc.)
.build
.unwrap;
Default timeouts: 30s connect / 60s read for standard endpoints, 30s connect / 1 hour read for the enterprise endpoint. Pass EnterpriseOptions { timeout: Some(_), .. } per call to override.
Choosing a TLS backend
The default build uses rustls with the Mozilla CA bundle — pure-Rust, no system dependencies, the right choice for most users. If you need OpenSSL (corp environments with custom CA trust stores, OpenSSL FIPS, regulatory constraints), opt into the native-tls feature instead:
[]
= { = "1.4", = false, = ["native-tls"] }
native-tls links against the system OpenSSL (via libssl-dev on Debian/Ubuntu, openssl-devel on Fedora). If the build host lacks those development headers but you still need the OpenSSL TLS stack at runtime, use vendored-openssl instead — it statically links a vendored copy of OpenSSL:
[]
= { = "1.4", = false, = ["vendored-openssl"] }
Available features:
| Feature | Default? | What it does |
|---|---|---|
rustls-tls |
yes | Pure-Rust TLS via rustls + Mozilla CA bundle |
native-tls |
no | Platform-native TLS (OpenSSL on Linux, SecureTransport on macOS, SChannel on Windows) |
vendored-openssl |
no | OpenSSL via native-tls, statically linked from a vendored source build |
Pick exactly one TLS backend; mixing rustls-tls with native-tls works (reqwest accepts both) but ships duplicate transport stacks.
Discriminating public vs custom matches
use ;
#
Custom catalog (advanced — not for music recognition)
⚠ The custom-catalog endpoint is NOT how you submit audio for music recognition. For recognition, use [
AudD::recognize] or [AudD::recognize_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.
# use AudD;
# async
Advanced
For lyrics search and a generic raw-request escape hatch:
# use AudD;
# async
Streams
Real-time recognition over an arbitrary streaming URL — the SDK manages add/list/delete and exposes a callback parser plus two longpoll modes.
# use AudD;
# async
Longpoll
# use ;
use StreamExt;
# async
Tokenless longpoll
For browser widgets, Twitch extensions, and other contexts where shipping the api_token would leak it:
use ;
use StreamExt;
# async
The consumer treats HTTP non-2xx responses as AudDError::Server (with the status preserved) instead of looping silently — important for browser deployments where the upstream might be misconfigured.
Spec contract
This SDK builds against the audd-openapi spec. The contract tests in tests/contract.rs 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