Hi,
I am having an issue where the API is not returning all the releases or release-groups for a recording.
Example: I have a CD Creedence Clearwater Revival - The Singles Collection with the track I Put A Spell On You (MBID 214f85d2-e95c-4c45-9aa6-e57fc84d3e2c). When I do a recording query
https://musicbrainz.org/ws/2/recording/214f85d2-e95c-4c45-9aa6-e57fc84d3e2c?inc=artists+releases+release-groups+artist-credits+genres+tags+media
It does NOT return The Singles Collection as a release (or release-group). Why would this be happening?
I have tried it with both XML and JSON, no difference. I can find it using the Web interface.
Thanks
The query that you’ve shown is a “lookup” query, with some additional included types. By design, the API will only show up to 25 related items in a lookup query, even if there are more.
In order to get all of the related items, you have to do a browse query
https://musicbrainz.org/ws/2/release?recording=214f85d2-e95c-4c45-9aa6-e57fc84d3e2c&limit=100
I can see “The singles collection” in this response. This query can take a limit/offset to allow you to retrieve up to 100 items at a time.
3 Likes
Thank you very much for your reply @alastairp.
The information that I require is spread across - inc=artists+release-groups+artist-credits+genres+tags+media
So, to get this info I would record each of the release-ids returned by
https://musicbrainz.org/ws/2/release?recording=214f85d2-e95c-4c45-9aa6-e57fc84d3e2c
then issue a
https://musicbrainz.org/ws/2/release/release-id?inc=artists+release-groups+artist-credits+genres+tags+media
for each release-id - 104 times in this instance. Is that correct?
Is there a way to add an offset value to a lookup query?
or, can I specify that the MBID be greater than some value in a lookup query?
Thanks in advance
No, in a lookup query you cannot change limit or offset.
Yes, you’re right. In the general case you may have to do this. Note that with a browse query, some of your required includes are possible:
https://musicbrainz.org/ws/2/release?recording=214f85d2-e95c-4c45-9aa6-e57fc84d3e2c&inc=release-groups+artist-credits+media
And you may be able to combine some queries - e.g. if you’re looking for tags for an artist, get all of the artist ids first and deduplicate them if needed before performing the lookups, instead of querying each release individually. Of course, if you’re looking for release tags and genres, yes, you’ll have to look them up one by one.
3 Likes
Thank you @alastairp for that informative reply.
It is the genres and tags for the release that I am mainly interested in.
I have already tried the browse query with inc=release-groups+artist-credits+media but other key information is also missing - track-position, track-length (unless they are well hidden - I looked in both the XML & JSON results)…
If the browse query is intended to be the deeper reaching function of the lookup query, it should be able to deliver the same data - or shouldn’t it?
I am struggling to understand the reasoning why the limit to lookup query is fixed at 25 - can someone enlighten me?
So, I have no choice but to implement it in the long format - at least for now…
Would it be practical to ask for a change so that the browse and lookup queries return the same data (including genres & tags), or limit/offset values added to the lookup query? Or both?
I just sent a patch to add tags and genres to browse release requests, since there seems to be no good reason for them to not allow them. So hopefully we’ll allow this in a few weeks, assuming the rest of the team agrees and there isn’t a very good reason for this that I’m missing
Funnily enough, I hadn’t seen this thread before that (@alastairp just pointed me to it) - I just happened to be updating the documentation for the WS to add genre includes and was confused to read we didn’t support this for release browses!
4 Likes
You also need to inc=recordings
1 Like