MusicBrainz metadata block
How to request and read the MusicBrainz metadata block on an AudD match: an array of recordings with MBIDs, ISRCs, match scores, and expanded releases.
Add musicbrainz to the return parameter and the result gets a musicbrainz field: an array of objects, which are the matching MusicBrainz recordings. A single recognized song can generate more than one MusicBrainz match. Each item in the array is a MusicBrainz recording object.
| Block | Shape |
|---|---|
apple_music, spotify, deezer | single object |
musicbrainz | array of recordings, with releases expanded |
Requesting the block
When you make a request with the SDKs, the return parameter is passed as an option to the recognize method. For Python, use the return_metadata option to pass the list of providers. In the other SDKs, the option has the same name in the language’s own case: returnMetadata in Node, for example.
from audd import AudD
audd = AudD("your-api-token") # dashboard.audd.io
result = audd.recognize(
"https://audd.tech/example.mp3",
return_metadata=["musicbrainz"],
)
import { AudD } from "@audd/sdk";
const audd = new AudD({ apiToken: "your-api-token" }); // dashboard.audd.io
const result = await audd.recognize("https://audd.tech/example.mp3", {
returnMetadata: ["musicbrainz"],
});
For cURL, add the return form field, then list the provider in the form return=musicbrainz.
curl https://api.audd.io/ \
-F api_token=your-api-token \
-F url=https://audd.tech/example.mp3 \
-F return=musicbrainz
Reading the block
The Python example picks the recording with the highest score; the Node example takes the first one.
result = audd.recognize(
"https://audd.tech/example.mp3",
return_metadata=["musicbrainz"],
)
entries = result.musicbrainz or [] # None if not requested / no match
if entries:
top = max(entries, key=lambda e: e.score or 0)
mbid = top.id # Recording MBID
page = f"https://musicbrainz.org/recording/{mbid}"
title = top.title
extra = top.model_extra or {}
isrcs = extra.get("isrcs") or [] # the recording's ISRCs
releases = extra.get("releases") or []
const entries = result.musicbrainz ?? []; // undefined if not requested / no match
if (entries.length) {
const top = entries[0];
const mbid = top.id; // Recording MBID
const isrcs = top.isrcs; // plain object key
}
In Python, result.musicbrainz is list[MusicBrainzEntry] (or None), with id, score, title and length as attributes and everything else in model_extra. In Node, it’s an array of plain objects (or undefined): read any key directly, e.g. top.isrcs or top["artist-credit"].
The recording MBID is the id field. The id can be used to generate the URL of the recording page: https://musicbrainz.org/recording/<id>. You can use the MusicBrainz API to get the recording’s relationships, works, and more.
Fields
Recording object
| Field | Type | Description |
|---|---|---|
id | string | the Recording MBID |
score | int or string | MusicBrainz’s own 0–100 match score: pick the highest, or take the first element |
title | string | the recording title |
length | int | the recording length, in milliseconds |
isrcs | array of strings | the recording’s ISRCs |
artist-credit | array of objects | the artist credit |
video | boolean or null | the video flag |
tags | array of objects or null | the tags |
releases | array of release objects | the releases the recording appears on |
Release object
| Field | Type | Description |
|---|---|---|
id | string | the release MBID |
title | string | the release title |
status | string | the release status |
track-count | int | the number of tracks |
release-group | object | the release group |
The keys come straight from the MusicBrainz API (hyphenated, e.g. artist-credit). For the full schema, see the MusicBrainz Recording and Release documentation.
Missing data
By default, the API doesn’t return the musicbrainz block. If the server has successfully processed the request but MusicBrainz has no match for the recording, the block can be null or absent, even if you asked for it. Any field of a recording or release can be absent or null (real responses can have "video": null and "tags": null), so check each value before you use it.
Links to MusicBrainz and streaming services
There is no “open in MusicBrainz” redirect. Use the recording’s MBID page instead. MusicBrainz is a database, not a streaming service, and the streaming_url() method doesn’t accept it.
We add URLs of song pages with links to the streaming platforms to the metadata we send with all the results: song_link links to a lis.tn song page like https://lis.tn/NbkVb. The SDKs have a streaming_url() method on the result that returns the URL of the recognized song on one streaming service. The providers you can pass: spotify, apple_music, deezer, youtube. For more information, see “The lis.tn song link.”
Related
Reading this as an AI agent? The raw Markdown is at reference/musicbrainz.md, and the full index is /resources/llms.txt.
