
MusicBrainz
MusicMusicBrainz is an open music encyclopedia that collects music metadata and makes it available to the public. The web service root URL is https://musicbrainz.org/ws/2/. We have 12 resources on our web service which represent core entities in our database: area, artist, event, instrument, label, place, recording, release, release-group, series, work, url. We also provide a web service interface for the following non-core resources: rating, tag, collection. And we allow you to perform lookups based on other unique identifiers with these resources: discid, isrc, iswc.
π Documentation & Examples
Everything you need to integrate with MusicBrainz
π Quick Start Examples
// MusicBrainz API Example
const response = await fetch('https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);MusicBrainz Public API Docs
MusicBrainz is a community-maintained open-source database that collects information about music artists, releases, and tracks. It provides a public API that allows developers to access this rich data and build innovative music applications.
The MusicBrainz Public API supports REST conventions over HTTP through XML web services. This documentation covers the Version 2 of the MusicBrainz API. In this blog, we will explore the MusicBrainz API and how to use it with JavaScript.
Getting Started β No API Key Required
MusicBrainz needs no API key and no authentication for read and search queries β you call the web service anonymously. Authentication (via OAuth) is only required to submit or edit data, not to look things up.
Two rules apply instead of a key:
- Set a descriptive
User-Agentheader identifying your app and a contact (email or URL). Requests with a generic or missing User-Agent may be blocked. - Stay under 1 request per second. Exceeding this rate gets your IP throttled or blocked.
Add &fmt=json to get JSON instead of the default XML:
fetch('https://musicbrainz.org/ws/2/artist?query=Coldplay&fmt=json', {
headers: { 'User-Agent': 'MyMusicApp/1.0 (you@example.com)' }
})
.then(res => res.json())
.then(data => console.log(data.artists[0].name));
The base URL is https://musicbrainz.org/ws/2/. There is no Authorization: Bearer token for reads β any example showing one (including elsewhere in older docs) is incorrect.
API Endpoints
The MusicBrainz API provides endpoints to retrieve different types of data including artists, releases, and tracks. Here are some of the endpoints that you can use with JavaScript:
Search Artists
const artistName = 'Linkin Park';
const requestUrl = `https://musicbrainz.org/ws/2/artist?query=${artistName}&fmt=json`;
fetch(requestUrl, {
headers: {
'User-Agent': 'My Music App',
'Authorization': 'Bearer YOUR_API_KEY',
},
})
.then((response) => response.json())
.then((data) => {
console.log(data.artists);
})
.catch((error) => {
console.error(error);
});
Get Artist
const artistId = '0039c7ae-e1a7-4a7d-9b49-0cbc716821a6';
const requestUrl = `https://musicbrainz.org/ws/2/artist/${artistId}?inc=aliases&fmt=json`;
fetch(requestUrl, {
headers: {
'User-Agent': 'My Music App',
'Authorization': 'Bearer YOUR_API_KEY',
},
})
.then((response) => response.json())
.then((data) => {
console.log(data.name);
})
.catch((error) => {
console.error(error);
});
Search Releases
const artistName = 'Radiohead';
const requestUrl = `https://musicbrainz.org/ws/2/release?query=artist:${artistName}&fmt=json`;
fetch(requestUrl, {
headers: {
'User-Agent': 'My Music App',
'Authorization': 'Bearer YOUR_API_KEY',
},
})
.then((response) => response.json())
.then((data) => {
console.log(data.releases);
})
.catch((error) => {
console.error(error);
});
Get Release
const releaseId = 'c032e638-1bea-4f0e-8e92-38182c3f560c';
const requestUrl = `https://musicbrainz.org/ws/2/release/${releaseId}?inc=labels&fmt=json`;
fetch(requestUrl, {
headers: {
'User-Agent': 'My Music App',
'Authorization': 'Bearer YOUR_API_KEY',
},
})
.then((response) => response.json())
.then((data) => {
console.log(data.title);
})
.catch((error) => {
console.error(error);
});
Search Recordings
const trackName = 'Paradise';
const artistName = 'Coldplay';
const requestUrl = `https://musicbrainz.org/ws/2/recording?query=${trackName} AND artist:${artistName}&fmt=json`;
fetch(requestUrl, {
headers: {
'User-Agent': 'My Music App',
'Authorization': 'Bearer YOUR_API_KEY',
},
})
.then((response) => response.json())
.then((data) => {
console.log(data.recordings);
})
.catch((error) => {
console.error(error);
});
Get Recording
const recordingId = 'ab197732-20e5-4e4b-8f20-02d5b589defb';
const requestUrl = `https://musicbrainz.org/ws/2/recording/${recordingId}?inc=isrcs&fmt=json`;
fetch(requestUrl, {
headers: {
'User-Agent': 'My Music App',
'Authorization': 'Bearer YOUR_API_KEY',
},
})
.then((response) => response.json())
.then((data) => {
console.log(data.title);
})
.catch((error) => {
console.error(error);
});
Conclusion
The MusicBrainz Public API provides a wealth of data that can be used to build innovative music applications. With the help of JavaScript, you can easily incorporate this data into your web application and create a seamless music browsing experience for your users.
Explore the MusicBrainz API documentation to discover more endpoints and start building amazing music apps today!









