How to retrieve recording relationship on release browse request on musicbrainz

606 Views Asked by At

i'm currently getting needed information from musicbrainz, using the following browse request, browsing a specific artists releases + recordings. for example: (coldplay)

http://musicbrainz.org/ws/2/release?artist=cc197bad-dc9c-440d-a5b5-d52ba2e14234&fmt=json&inc=recordings

im interested in getting for each recording its work id. now i tried adding 'recording-rels' to the includes but it seems only to return relationship between release and recording. I also tried adding 'recording-level-rels' to includes as mentioned here where it states that it should return recordings relationships, but when i try using it - i get the following error:

{"error":"recording-level-rels is not a valid inc parameter for the release resource."}

Am I using it wrongly? To clarify, i'm after the relationship that you get from their site, say from this page, where each release has recording of that contains a link to the musicbrainz work id page.

Any help\advice would be very appreciated, Thank you.

2

There are 2 best solutions below

0
On BEST ANSWER

Well, like you said: What you are doing is a browse request and the relationships you linked only work for release lookups.

So you can't get this information with one request. The simple solution for this is to use:
http://musicbrainz.org/ws/2/release?artist=cc197bad-dc9c-440d-a5b5-d52ba2e14234
to get all releases (without recordings) and for every release:
http://musicbrainz.org/ws/2/release/bfae6df7-3ee2-4031-ac09-8dc63c6ce6ca?inc=recordings+recording-level-rels+work-rels
to get the associated works.


The above method has the problem that you need one request for every release. You can do better if you do some matching on your end. You can get your list(s) of recordings with
http://musicbrainz.org/ws/2/release?artist=cc197bad-dc9c-440d-a5b5-d52ba2e14234&inc=recordings
and the works with:
http://musicbrainz.org/ws/2/work?artist=cc197bad-dc9c-440d-a5b5-d52ba2e14234&inc=recording-rels
Using this information you can then match the works with the recordings on the releases.

Alternatively you can also get all recordings using
http://musicbrainz.org/ws/2/recording?artist=cc197bad-dc9c-440d-a5b5-d52ba2e14234&inc=work-rels
but there are usually more recordings and less works. Meaning there is not always a work attached to every recording.

Note that this method also needs more than 2 requests when you need to use limit/offset to get multiple pages of results.

0
On

The link to the API documentation about relationships is for MBID lookups and works only for them. So this here works for example:

http://musicbrainz.org/ws/2/recording/7137bd5b-7f93-40c0-a780-53784a8f6c5d?inc=work-rels

But in a browse query, which you are doing, this relatioship cannot be queried. I guess you have two options: