Development/ws/js: Difference between revisions

From MusicBrainz Wiki
Jump to navigationJump to search
m (→‎Autocomplete: fixed typo)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
NOTE: the /ws/js webservice is considered to be part of the musicbrainz server code. it isn't version and may change at any time, please do not rely on it for anything important, use /ws/2 instead. (also note that the documentation here is currently incomplete and outdated).
=Autocomplete=

==Autocomplete==


Currently there is an autocomplete interface for artists and labels. A request looks like this:
Currently there is an autocomplete interface for artists and labels. A request looks like this:
Line 39: Line 41:
]
]


NOTE: there is also a seperate recording autocomplete lookup, but this isn't documented yet as it is scheduled to undergo some changes to share more code with the label/artist lookups.
NOTE: there is also a separate recording autocomplete lookup, but this isn't documented yet as it is scheduled to undergo some changes to share more code with the label/artist lookups.


=Tracklist=
==Tracklist==


The javascript webservice provides access to tracklists, this is mainly intended to lazy load them in the release editor. Simply provide the tracklist row id in a call to /ws/js/tracklist:


/ws/js/tracklist/184453
I think I want to render disc format and title as part of the collapsed discs, so they don't need to be included in a /ws/js call for the tracklist tab. If I also include the tracklist id when rendering the collapsed discs, I can just call:


The response will be a list of tracks with artist credits, as an example the response to the above request is:
/ws/js/tracklist/<tracklist-row-id>

And the response should be something like this (this example contains just one track, a typical tracklist will obviously have more tracks as part of the top-level array):


[
[
{
{
"length": "4:03",
"length": "6:11",
"title": "the Love Bug"
"name": "Glenn",
"artist": {
"artist_credit": {
"preview": "m-flo\u2665BoA",
"preview": "Slint",
"names": [
"names": [
{
{
"credit": "m-flo",
"gid": "2869c510-2679-4a3f-bf15-e5e8b49f2f28",
"gid": "22dd2db3-88ea-4428-a7a8-5cd3acf23175",
"join": null,
"join": "\u2665",
"name": "Slint",
"name": "m-flo"
"artist_name": "Slint"
},
}
]
}
},
{
"length": "6:54",
"name": "Rhoda",
"artist_credit": {
"preview": "Slint",
"names": [
{
{
"credit": "BoA",
"gid": "2869c510-2679-4a3f-bf15-e5e8b49f2f28",
"gid": "a16d1433-ba89-4f72-a47b-a370add0bb55",
"join": null,
"join": null,
"name": "BoA"
"name": "Slint",
"artist_name": "Slint"
}
}
]
]
},
}
}
}
]
]


[[Category:Development]]

further notes:

* the artist/recording lookups may use the external search, which uses GIDs instead of row ids, so for consistency it seems better to not use row ids in these json responses.

* including the artist credit preview isn't technically neccesary, we have code in javascript anyway to render artist credits, so you can leave it off if you prefer.

* if you want to name certain keys differently because of consistency with the database or the perl code, be my guest.

Latest revision as of 09:52, 24 August 2013

NOTE: the /ws/js webservice is considered to be part of the musicbrainz server code. it isn't version and may change at any time, please do not rely on it for anything important, use /ws/2 instead. (also note that the documentation here is currently incomplete and outdated).

Autocomplete

Currently there is an autocomplete interface for artists and labels. A request looks like this:

 /ws/js/artist?q=cycles&limit=3&page=1
 /ws/js/label?q=warp+records
  • q is the search term
  • limit is the max number of results on a page (optional)
  • page allows you to select the page, if there are more than limit results (optional)

The services provide a JSON formatted response which contains a list of search results. The final entry of the list is not a search result, but information about the search itself, so pop this off the list if you're only interested in the results themselves.

A response looks like this:

[
   {
       "comment": null, 
       "gid": "3c4524ce-dc16-4dbd-b52f-6e7f9f067f9a", 
       "name": "7 Cycles", 
       "id": "556345"
   }, 
   {
       "comment": "UK Based Electronica Producer Oliver Charles", 
       "gid": "d3423ede-83ba-4758-8e4c-4f0d5f0bfabd", 
       "name": "Cycles", 
       "id": "592771"
   }, 
   {
       "comment": null, 
       "gid": "8847a88f-5780-4224-b879-8dc15ce153a0", 
       "name": "Pharmakustik + Frequency in Cycles Per Second", 
       "id": "650671"
   }, 
   {
       "current": "1", 
       "pages": 2
   }
]

NOTE: there is also a separate recording autocomplete lookup, but this isn't documented yet as it is scheduled to undergo some changes to share more code with the label/artist lookups.

Tracklist

The javascript webservice provides access to tracklists, this is mainly intended to lazy load them in the release editor. Simply provide the tracklist row id in a call to /ws/js/tracklist:

 /ws/js/tracklist/184453

The response will be a list of tracks with artist credits, as an example the response to the above request is:

[
   {
       "length": "6:11", 
       "name": "Glenn", 
       "artist_credit": {
           "preview": "Slint", 
           "names": [
               {
                   "gid": "2869c510-2679-4a3f-bf15-e5e8b49f2f28", 
                   "join": null, 
                   "name": "Slint", 
                   "artist_name": "Slint"
               }
           ]
       }
   }, 
   {
       "length": "6:54", 
       "name": "Rhoda", 
       "artist_credit": {
           "preview": "Slint", 
           "names": [
               {
                   "gid": "2869c510-2679-4a3f-bf15-e5e8b49f2f28", 
                   "join": null, 
                   "name": "Slint", 
                   "artist_name": "Slint"
               }
           ]
       }
   }
]