how to get album image using musicbrainz

Rahil2952 picture Rahil2952 · Nov 19, 2012 · Viewed 9.2k times · Source

I don't know whether I can ask such question here or not. My question is as below.

I am making music player on my own and I want to download album images for those songs which don't have album image. Just like what N7Music Player is doing. I did some search on my own and I came to know that using MusicBrainz we can download images.

I looked for its API but I am not getting it clearly. I have following doubts.

  1. How to get its API key?
  2. Is it free?
  3. How to make call to API if artist and song name is known to fetch album image for that song?

I am waiting for your valuable responses.

Thanking you in advance.

Answer

warp picture warp · Nov 19, 2012

The first thing you need to do is figure out a release identifier (release MBID) for the album you want to get images from, you can do that using the search API, for example:

http://www.musicbrainz.org/ws/2/recording/?query=artist:nikes+recording:ftg2

Because it is a search, you will get many results, some of them will be wrong. In this case the first result is correct and only matches one release, it has the following MBID: "c04730ea-87cb-478b-a256-08c0561d20e6".

Now that you have an identifier, you can do a lookup at the coverartarchive:

http://coverartarchive.org/release/c04730ea-87cb-478b-a256-08c0561d20e6/

Which will give you a json response with a list of available images (or a 404 if that release doesn't have cover art in the coverartarchive).

The coverartarchive is fairly new however, and may not always have cover art. MusicBrainz sometimes has a link to cover art, which you can look for by including "url-rels" in a webservice request, for example for the release MBID "fdfdb3c0-8820-4c22-94e6-6aa136e36c31" you can do this request:

http://musicbrainz.org/ws/2/release/fdfdb3c0-8820-4c22-94e6-6aa136e36c31?inc=url-rels

And in the output you will see an url to an image:

<relation type="cover art link">
    <target>http://liveweb.archive.org/http://www.8bitpeoples.com/images/albums/large/8BP049.gif</target>
</relation>