Get original album release for a song

First of all thanks in advance for any help. I looked everywhere and could not find any solution to what seems to be a simple problem. I’m hitting the API to get info for a song, let’s say Breathru by Queen. Once I find it I need to know what album the song was released on, assuming the most likely result is the first release and not greatest hits, etc. I cannot in any way find that information. If I run this query:

https://musicbrainz.org/ws/2/release?query=""Queen%20Breakthru"&fmt=json

I’m getting 3 results for Breakthru by Queen but with no album data associated.

If I query for “Queen The Miracle” the album pops up and the song is there in the tracks linked to the album, but I just can’t pull the album from the song search. Does anyone know how this is done? Thanks!

I don’t think that your assumption is correct. The result will return all existing releases found on MB, not only the “first” or “best” release.

If you have a look at the API documentation you will find many examples.
There is also a section about Subqueries executed with the inc= parameter.

3 Likes

I mean, I would be fine with any version of the album, but none pops up

https://musicbrainz.org/ws/2/release?query=""Queen%20Breakthru"&inc=release-groups&fmt=json

What would be the correct inc parameter to include the album(s) the song belongs to?

You could try it for example with an URL like this:
https://musicbrainz.org/ws/2/recording/?query=recording:Breakthru%20AND%20artist:Queen&inc=releases

If you are only interested in what can be considered the original album or kind of the canonical release or release group for a specific recording you could consider using the ListenBrainz API. ListenBrainz needs this information as well and has datasets that specifically provides this information.

The following query gets this information based on the artist and the recording name:

https://api.listenbrainz.org/1/metadata/lookup/?artist_name=Queen&recording_name=Breakthru&metadata=true&inc=release

See also Metadata — ListenBrainz 0.1.0 documentation

4 Likes

This is an excellent suggestion, thank you!