Best way to get cover art when only a RecordingID is known

Tags: #<Tag:0x00007f2a056a7418> #<Tag:0x00007f2a056a70a8> #<Tag:0x00007f2a056a6e00> #<Tag:0x00007f2a056a6ab8>


I’m writing this app in javascript, and I need a function which can return the front cover art when all I have is a Recording_ID (rid) value. I can get the releaseID from that, and the cover-art from the releaseID - unless there’s a better way?

So I figured I could do it with a json post call, but I think I’m missing the syntax for adding authentication to the Get call.

Can anyone show me some example javascript which works with authentication to make a musicbrainz query like this, (for example) and returns the result in json format?

Thanks in advance.


If you have the ID already you can query the recording directly:


You are likely being blocked by rate limiting as you have not set a user agent string.
I have no idea how to change this in java script.

A recording can exist on multiple releases.
Not all releases have cover art and you will need to work out what release is the best for your needs.
You may want to find singles/ep’s then the album and avoid using cover art from a random compilation.


Thanks for your replies guys. I need to clarify my question: Following is the key lines of javascript I’m trying to use to send a POST request in json format to musicbrainz:

var rUrl=“”;
var inc="?inc=releases"
var fMt = "&fmt=json"
var relID = ""
var urlCall = rUrl + Rid + inc + fMt
$.post(urlCall, function(results) {
relID = results.recordings[0].releases[0].id;

The set of variables above sends a post in this format to MB:

… and that works fine in my browser.

However, I’m given a 401 unauthorised error in the console when running it from js, presumably because I’m not authorising it correctly. I think I should be specifying the user-agent somehow but I just don’t know how in js, and can’t find any examples online.

Can anyone can show me how to add the user-agent info, and authorise my MB request in a javascript call?



There is no authorization involved here, you simply need to use a GET, not a POST :wink: