javascriptd3.jsmusicbrainz

returning band members from musicbrainz


I've a reasonable amount of experience using javascript but never made a call to an external database, so this is new ground for me. I'm trying to return the members of a band as a json object from the Musicbrainz database. At the moment it doesn't matter which group so lets just say Nirvana as thats one of their examples. I've tried this:

var url = "http://musicbrainz.org/ws/2/artist/5b11f4ce-a62d-471e-81fc-a69a8278c7da?inc=url-rels&fmt=json";
  d3.json(url, function (json) {
    console.log(json)

  });

But that doesn't give me what I thought. I expected that the relationship array would contain the band members, start and end date etc, but thats not so. I get this back and the relationship array contains other data such as TV appearances

(index):19 Objectarea: Objectbegin_area: Objectcountry: "US"disambiguation: "90s US grunge band"end_area: nullgender: nullgender-id: nullid: "5b11f4ce-a62d-471e-81fc-a69a8278c7da"ipis: Array[0]isnis: Array[1]life-span: Objectname: "Nirvana"relations: Array[38]0: Object1: Object2: Object3: Object4: Object5: Object6: Object7: Object8: Object9: Object10: Object11: Object12: Object13: Object14: Object15: Object16: Object17: Object18: Object19: Object20: Object21: Object22: Object23: Object24: Object25: Object26: Object27: Object28: Object29: Object30: Object31: Object32: Object33: Object34: Object35: Object36: Object37: Objectlength: 38__proto__: Array[0]sort-name: "Nirvana"type: "Group"type-id: "e431f5f6-b5d2-343d-8b36-72607fffb74b"__proto__: Object

Could anyone help me out please or point me in the direction. I'm working in javascript.

Thanks

Thanks


Solution

  • Per the documentation, it looks like you need to add artist-rels to the subquery to get the band members, like this:

    http://musicbrainz.org/ws/2/artist/5b11f4ce-a62d-471e-81fc-a69a8278c7da?inc=url-rels%20artist-rels&fmt=json