Computer
Computer

Reputation: 2227

Musicbrainz querying artist and release

I am trying to get an artist and their albums. So reading this page https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2 i created the following query to get Michael Jackson's albums

http://musicbrainz.org/ws/2/artist/?query=artist:michael%20jackson?inc=releases+recordings

My understanding is to add ?inc=releases+recordings at the end of the URL which should return Michael Jackson's albums however this doesnt seem to return the correct results or i cant seem to narrow down the results? I then thought to use the {MBID} but again thats not returned in the artists query (which is why im trying to use inc in my query)

http://musicbrainz.org/ws/2/artist/?query=artist:michael%20jackson

Can anyone suggest where im going wrong with this?

Upvotes: 1

Views: 3193

Answers (1)

SuN
SuN

Reputation: 1056

You're not searching for the correct Entity. What you want is to get the discography, not artist's infos. Additionally, query fields syntax is not correct (you must use Lucene Search Syntax).

Here is what you're looking for:

http://musicbrainz.org/ws/2/release-group/?query=artist:"michael jackson" AND primarytype:"album"

We're targeting the release-group entity to get the albums, searching for a specific artist and filtering the results to limit them to albums. (accepted values are: album, single, ep, other)

There are more options to fit your needs, for example you can filter the type of albums using the secondarytype parameter. Here is the query to retrieve only live albums:

http://musicbrainz.org/ws/2/release-group/?query=artist:"michael jackson" AND primarytype:"album" AND secondarytype="live"

Here is the doc: https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2/Search

Note that to be able to use MB's API you need to understand how it is structured, especially, the relations between release_group, release and medium.

Upvotes: 4

Related Questions