MusicBrainz API/Examples: Difference between revisions

From MusicBrainz Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 2: Line 2:
Getting a JSON response will require setting the Accept header to "application/json".
Getting a JSON response will require setting the Accept header to "application/json".


The most important difference with the JSON response currently used internally by the search server is
Some notable differences compared to the JSON response currently used internally by the search server:
that all "-list" elements are replaced with javascript arrays, using an english plural as the key.
# all "-list" elements are replaced with javascript arrays, using an english plural as the key. So { "tag-list": { "tag": [ ... ] } } becomes { "tags": [ ... ] }.
# the "name-credit" key inside an "artist-credit" is removed.
So { "tag-list": { "tag": [ ... ] } } becomes { "tags": [ ... ] }.

Some of the response below have some fields omitted to keep the examples shorter, in the actual webservice obviously this data will be included.


==Artist==
==Artist==
Line 103: Line 105:
}
}
]
]
}
}
</code>

==Recording==

Request: http://musicbrainz.org/ws/2/recording/fcbcdc39-8851-4efc-a02a-ab0e13be224f?inc=artist-credits+isrcs+releases
Response:

<code>
{
"recording": {
"id": "fcbcdc39-8851-4efc-a02a-ab0e13be224f",
"title": "LAST ANGEL"
"disambiguation": "video"
"artist-credit": [
{
"name": "\u6771\u65b9\u795e\u8d77",
"joinphrase": " feat. ",
"artist": {
"id": "455641ea-fff4-49f6-8fb4-49f961d8f1ac",
"name": "\u6771\u65b9\u795e\u8d77",
"sort-name": "Koda, Kumi"
}
},
{
"name": "\u5016\u7530\u4f86\u672a",
"artist": {
"id": "05cbaf37-6dc2-4f71-a0ce-d633447d90c3",
"name": "\u5016\u7530\u4f86\u672a",
"sort-name": "TVXQ"
}
}
],
"isrcs": [ "JPB600760301" ],
"length": 228106,
"releases": [
{
"id": "abcd76db-7d5f-3eb7-b386-051c97bfe2e4",
"title": "Kingdom"
}
],
}
}
}
}

Revision as of 12:09, 5 July 2012

This document describes the proposed JSON output, using example queries and the responses I am proposing. Getting a JSON response will require setting the Accept header to "application/json".

Some notable differences compared to the JSON response currently used internally by the search server:

  1. all "-list" elements are replaced with javascript arrays, using an english plural as the key. So { "tag-list": { "tag": [ ... ] } } becomes { "tags": [ ... ] }.
  2. the "name-credit" key inside an "artist-credit" is removed.

Some of the response below have some fields omitted to keep the examples shorter, in the actual webservice obviously this data will be included.

Artist

Request: http://musicbrainz.org/ws/2/artist/5b11f4ce-a62d-471e-81fc-a69a8278c7da?inc=aliases Response:

{
   "artist": {
       "id": "5b11f4ce-a62d-471e-81fc-a69a8278c7da"
       "name": "Nirvana",
       "sort-name": "Nirvana"
       "type": "Group",
       "country": "US",
       "disambiguation": "90s US grunge band",
       "life-span": {
           "ended": true,
           "begin": "1988-02",
           "end": "1994-04-05"
       },
       "aliases": { "name": "Nirvana US", "sort-name": "Nirvana US" },
   }
}

Request: http://musicbrainz.org/ws/2/artist/05cbaf37-6dc2-4f71-a0ce-d633447d90c3?inc=aliases+tags+ratings Response:

{
   "artist": {
       "id": "05cbaf37-6dc2-4f71-a0ce-d633447d90c3",
       "name": "\u6771\u65b9\u795e\u8d77",
       "sort-name": "TVXQ",
       "type": "Group",
       "life-span": {
           "ended": false,
           "begin": "2003"
       },
       "aliases": [
           { "name": "DBSK", "sort-name": "DBSK" },
           { "name": "Tohoshinki", "sort-name": "Tohoshinki", "locale": "ja", "primary": true },
           { "name": "\ub3d9\ubc29\uc2e0\uae30", "sort-name": "\ub3d9\ubc29\uc2e0\uae30", "locale": "ko_KR", "primary": true }
       ],
       "tags": [
           { "count": 1, "name": "kpop" },
           { "count": 1, "name": "jpop" },
           { "count": 1, "name": "cpop" }
       ],
       "rating": { "votes-count": 8, "value": 3.9 }
   }
}

Label

Request: http://musicbrainz.org/ws/2/label/46f0f4cd-8aab-4b33-b698-f459faf64190?inc=aliases Response:

{
   "label": {
       "id": "46f0f4cd-8aab-4b33-b698-f459faf64190",
       "name": "Warp Records",
       "sort-name": "Warp Records",
       "label-code": 2070,
       "type": "Original Production",
       "country": "GB",
       "life-span": {
           "ended": false,
           "begin": "1989"
       },
       "tags": [ { "count": 2, "name": "electronic" } ]
   }
}

Request: http://musicbrainz.org/ws/2/label/f49e877d-df8d-4a28-bbe1-689d12fc7d91?inc=aliases Response:

{
   "label": {
       "id": "f49e877d-df8d-4a28-bbe1-689d12fc7d91"
       "name": "AVEX ENTERTAINMENT INC.",
       "sort-name": "AVEX ENTERTAINMENT INC.",
       "type": "Production",
       "country": "JP",
       "disambiguation": "avex's Japanese music production",
       "life-span": { "ended": false },
       "aliases": [
           { "name": "AVEX MARKETING", "sort-name": "AVEX MARKETING" },
           { "name": "avex marketing", "sort-name": "avex marketing" },
           {
               "name": "\u30a8\u30a4\u30d9\u30c3\u30af\u30b9\u30fb\u30a8\u30f3\u30bf\u30c6\u30a4\u30f3\u30e1\u30f3\u30c8",
               "sort-name": "\u30a8\u30a4\u30d9\u30c3\u30af\u30b9\u30fb\u30a8\u30f3\u30bf\u30c6\u30a4\u30f3\u30e1\u30f3\u30c8"
           }
       ]
   }
}

Recording

Request: http://musicbrainz.org/ws/2/recording/fcbcdc39-8851-4efc-a02a-ab0e13be224f?inc=artist-credits+isrcs+releases Response:

{
   "recording": {
       "id": "fcbcdc39-8851-4efc-a02a-ab0e13be224f",
       "title": "LAST ANGEL"
       "disambiguation": "video"
       "artist-credit": [
           {
               "name": "\u6771\u65b9\u795e\u8d77",
               "joinphrase": " feat. ",
               "artist": {
                   "id": "455641ea-fff4-49f6-8fb4-49f961d8f1ac",
                   "name": "\u6771\u65b9\u795e\u8d77",
                   "sort-name": "Koda, Kumi"
               }
           },
           {
               "name": "\u5016\u7530\u4f86\u672a",
               "artist": {
                   "id": "05cbaf37-6dc2-4f71-a0ce-d633447d90c3",
                   "name": "\u5016\u7530\u4f86\u672a",
                   "sort-name": "TVXQ"
               }
           }
       ],
       "isrcs": [ "JPB600760301" ],
       "length": 228106,
       "releases": [
           {
               "id": "abcd76db-7d5f-3eb7-b386-051c97bfe2e4",
               "title": "Kingdom"
           }
       ],
   }
}