How to get/search cover image of track?

Hi,

I want to get the cover image of track. How can i do that? Can anybody give an example?

Thanks

Can you give us the MusicBrainz-URL for your track, like

Let me describe what i want to achieve…

-> user can search track cover image by name and it should return list of images from which user can select correct track image .

I did’t get what do you mean by ‘MusicBrainz-URL’?

First thing to note is that MusicBrainz does not store images per track, but per release. Is that what you want?

Also it is not clear what exactly you are doing. Are you developing some software, and in that software the user can search for a track name and get the corresponding album artwork?

If that’s the use case you can use the MusicBrainz API and Cover Art Archive API for this.

The basic idea would be that you search for a recording with the entered name and include all releases with the result, like this for “Paint it Black”:

https://musicbrainz.org/ws/2/recording/?query=recording:"Paint%20It%20Black"%20AND%20status:official%20AND%20primarytype:album&inc=releases

There might be more than one recording, so you will have to look at several for the best match for your use case. A recording will also be often on multiple releases, so you have to filter the releases as well. Maybe you want to focus on primarytype “album” and secondarytype not set at all. If there is not primarytype “album”, fall back to “single” or “ep”. Maybe sort by release date, so you get the earliest available one. You can also display the user multiple results.

Once you have a release ID you can query the Cover Art Service:

https://coverartarchive.org/release/37b9a29b-2d39-441b-9ac6-81770916e5b5

Not every release will have cover art of course.

4 Likes

@outsidecontext i need help here please with how to get a dexcription of the artist from wikidata by mapping MBID and Wikipedia-identifier throught MusicBrainz API

If you have the MBID of an artist you can query the artist’s URL relationships by including the url-rels inc parameter, e.g.:

https://musicbrainz.org/ws/2/artist/10bf95b6-30e3-44f1-817f-45762cdc0de0?inc=url-rels&fmt=json

This will include the wikidata identifier in the relations list with target-type set to “url” and type set to “wikidata”, in this case

{
    "source-credit": "",
    "ended": false,
    "attributes": [],
    "end": null,
    "begin": null,
    "attribute-values": {},
    "target-credit": "",
    "type": "wikidata",
    "attribute-ids": {},
    "url": {
        "id": "1781c847-6f5e-4731-a61a-fa3b4f84a0de",
        "resource": "https://www.wikidata.org/wiki/Q750593"
    },
    "type-id": "689870a4-a1e4-4912-b17f-7b2664215698",
    "target-type": "url",
    "direction": "forward"
}

You can use the Wikidata identifier (Q750593) to query details about the artist from Wikidata API. I don’t know the Wikidata API very well, but https://www.wikidata.org/wiki/Special:EntityData/Q750593.rdf would give you links to the Wikipedia entry.

1 Like

Thanks, in my case i use js as front end and Node js as backend,
i want when the user make a get request to /api/${queryByArtistMBID} from client to server, then the server makes fetch API to this base_url https://musicbrainz.org/ by doing following:
https://musicbrainz.org/ws/2/artist/queryByArtistMBID?inc=url-rels&fmt=json , once data is being fetched then how to fetch and query the artist’s details from wikidata, DO i need to make another fetch api request to this wikidata url https://www.wikidata.org/w/api.php by passing Wikidata identifier ( Q750593 ) ? has every artist it’s own wikidata identifier or just same for all artist when making fetching details from wikidata for specifik artist ?

here is what i see in some task but i don’t understand how this is configured to get details of the specifik artist that a user requsted
https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q11649&format=json&props=sitelinks

In my case i just need to get two thing when the user make a request to this api by passing MBID:
1- A detailsof the artist downloaded from Wikipedia.
2- A list of all albums released by that artist and links to images for each album, The list of albums is in MusicBrainz but the pictures are on the Cover Art Archive

this docs is https://www.npmjs.com/package/musicbrainz-api what i got so far but not yet understood really .

your help is very appreciated

You will need to make as many fetch calls as you need to get the information you want.
You need to look at what information you have and what information you can request.

So if you start from a recording id in musicbrainz what could you get?

  • Lookup the recording id in musicbrainz, what is it’s name, who are the artists, what releases contain this recording?
  • Look at each artist on the artist, what albums do they have? do they have a wikidata page? Is this an artist or a group and do we know the members of the group?
  • Look up the wikidata page, does it link to an English Wikipedia page? Can I get the first paragraph of that page? is there an image on wikimedia commons?

You will most likely need to make a whole bunch of queries to get each piece of information with each query adding just a little more information to the whole.
Each query might return 0 or many results so you need to work out what you want to do at each stage.
Not every artist has a wikidata / wikipedia page for example and there can be many artists that sing on the one song so do you look at just the first one listed or everyone?

This can be something you can design using a pen and paper to describe what you want and what steps you need to piece together to collect that.
Query this service, get a list of results, Look for results that meet this criteria call next service using this id etc.

2 Likes

@dns_server @outsidecontext thanks guys, just to understand little bit what is going on here, i share my firtst fetch api call server code using Node js and i’m fetching artist
https://codeshare.io/adZm7e ,this is what i get back from the server https://imgur.com/a/I9veNlo
i can’t see any artist property inside this data, so how to make another fetch call to wikidata to get the details of that artist by passing Q750593 ) along with the artist id ?

@outsidecontext Thank you, let’s say we have the artist MBID and we call this api https://musicbrainz.org/ws/2/artist/10bf95b6-30e3-44f1-817f-45762cdc0de0?inc=url-rels&fmt=json by passing that artist MBID, THis gives a data included that wikidata identifier to make another call to wikidata by using Wikidata identifier ( Q750593 ) to query details about the artist from Wikidata API,
Is this Wikidata identifier ( Q750593 ) same all time regardless artist when making request ?

should i not pass along with that specifik artist’s id when making another request to wikidata, see here without artist’s id https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q11649&format=json&props=sitelinks how would i get the details of that artist though ?

No. The Wikidata identifier is different for each artist.

I don’t know the Wikidata API very well, you’ll need to consult their documentation for details.

The link I posted above (https://www.wikidata.org/wiki/Special:EntityData/Q750593.rdf) gives as far as I can tell all the data for the artist with the Wiki data ID Q750593. As you are interested in the biographie from Wikipedia, Wikidata will not directly give you that. But Wikidata will give you the links to Wikipedia for various languages. You’ll need to query Wikipedia separately for the text content. I personally don’t know how to do this, though.

2 Likes

@rdswift so i don’t see any type of wikidata identifier like this ( Q750593 ) attached to the tha data i get back from the url call , here is the relations list. can you point the wikidata identifier from this block

{
“source-credit”: “”,
“ended”: false,
“attributes”: [],
“end”: null,
“begin”: null,
“attribute-values”: {},
“target-credit”: “”,
“type”: “wikidata”,
“attribute-ids”: {},
“url”: {
“id”: “1781c847-6f5e-4731-a61a-fa3b4f84a0de”,
“resource”: “https://www.wikidata.org/wiki/Q750593
},
“type-id”: “689870a4-a1e4-4912-b17f-7b2664215698”,
“target-type”: “url”,
“direction”: “forward”
}

As I wrote in a post above you need to add the inc=url-rels parameter to your API call. See my earlier post for details.

I don’t know how to pass Inc parameters when using the node library, but their documentation should help.

1 Like

The last part of the resource string is the Wikidata identifier.

1 Like

thanks, if i need to acces image of an album throught http://coverartarchive.org/ what query to pass into this url ? i tried this https://ia803208.us.archive.org/11/items/mbid-a146429a-cedc-3ab0-9e41-1aaf5f6cdc2d/index.json and it works fine and gives back image of the album

but if i change the mbid to another exist album with id e.g https://ia803208.us.archive.org/11/items/mbid-f1afec0b-26dd-3db5-9aa1-c91229a74a24/index.json that doesn’t give me any image

The reason is that your second request is passing the MBID for the release group rather than the release.

I think the correct url endpoint is http://coverartarchive.org/release-group/01cf1391-141b-3c87-8650-45ade6e59070
and the mbid is coming after release-group/
that works for me but i don’t if it’s the correct way to do it

I believe that’s the correct way to do it if you’re looking up by release group rather than by release.

@rdswift thank you so much, yeah i think so too, in other words ‘release-group’ means all the albums for a single artist right ?
I need to display all the albums that was released by a specific artist with with specific mbid,