Get list of studio albums with API

I am using the musicbrainz API, and am trying to get a list of studio albums like you see on this page:

https://musicbrainz.org/artist/8e3fcd7d-bda1-4ca0-b987-b8528d2ee74e

In the JSON data that I get back, I see there is “secondary-type”, which I can use to filter out things like compilations.

    {
        "first-release-date": "1990",
        "primary-type-id": "f529b476-6e62-324f-b0aa-1f3e33d313fc",
        "disambiguation": "",
        "primary-type": "Album",
        "secondary-types": [
            "Compilation"
        ],
        "title": "Trespass / Nursery Cryme / Foxtrot",
        "id": "130f44c3-0bf5-453f-bed1-6f473342c13d",
        "secondary-type-ids": [
            "dd2a21e1-0c00-3729-a7a0-de60b84eb5d1"
        ]
    }

But I notice some entries don’t have anything for “secondary-type”, for example:

    {
        "first-release-date": "1978",
        "disambiguation": "",
        "primary-type-id": "f529b476-6e62-324f-b0aa-1f3e33d313fc",
        "primary-type": "Album",
        "secondary-types": [],
        "title": "All We Need’s a Hit",
        "id": "bc68ceea-7838-4c1d-8cc0-920ca1dc55d9",
        "secondary-type-ids": []
    }

How is it that the musicbrainz page in the screenshot above filters out albums like this, but I don’t have any criterion in the returned JSON that I can use to do the same ?

The criterion is specifically “secondary types is blank” - if they had a secondary type, they’d be put elsewhere in the MusicBrainz display as well :slight_smile: If something that should be live, compilation or whatnot has no secondary types, then that’s not an API issue, but an error with the MusicBrainz data (feel free to submit an edit to improve it!).

2 Likes

Thanks for the reply.

If you look at the musicbrainz page I am talking about, you will see, for example, that “All We Needs a Hit” does not appear in the list of albums even though in the JSON returned it does not seem to have any fields that would distinguish it from the albums in the list.

Which makes me think that there must be some sort of additional data in the database that is not being included as part of the returned JSON.

Compare it, for example, with:

{
“id”: “ffcfe407-d820-38ba-a798-8734b5dff61c”,
“secondary-type-ids”: [],
“secondary-types”: [],
“title”: “Duke”,
“primary-type”: “Album”,
“first-release-date”: “1980-03-28”,
“disambiguation”: “”,
“primary-type-id”: “f529b476-6e62-324f-b0aa-1f3e33d313fc”
}

This case is a bit tricky to handle in the API I think.

This specific release group is not shown because the only release in it is a bootleg. So to fix this you’d need to query the releases, filter them for unwanted releases (bootleg, demo, promotional?) and only include the release group if it has wanted releases.

CritiqueBrainz suffers from the same issue / limitation, see e.g. https://critiquebrainz.org/artist/8e3fcd7d-bda1-4ca0-b987-b8528d2ee74e?release_type=album&page=7

Related issue:

4 Likes

Thanks for the explanation for this. It will probably be a few days before I have a chance to take a look at the returned JSON again. Will let you know if I was able to work around the issue.

Thanks for pointing me in the right direction guys.

In the end, I was able to get the results I wanted with this query:

https://musicbrainz.org/ws/2/release?artist=8e3fcd7d-bda1-4ca0-b987-b8528d2ee74e&inc=release-groups&status=official&type=album&limit=100&fmt=json

The status=official option only works with the “release” end point, but by including “inc=release-groups” I was able to filter the data on secondary-types.

2 Likes