Does musicbrainz api support jsonp?

Tags: #<Tag:0x00007f0507de1a30> #<Tag:0x00007f0507de18f0> #<Tag:0x00007f0507de17b0> #<Tag:0x00007f0507de1670> #<Tag:0x00007f0507de1530>



I’m trying to retrieve artist information with in a ui5 / javascript.

In order to avoid cross domain origin requests CORS ( I also do a bandsintown api request) I need to do this request with a json procedure, a jsonp.
My question is if Musicbrainz supports jsonp. I cannot find anything in the api description about this and i cannot get it to work. This may be because of my sadly deficient programming skills, but if musicbrainz doesnt support jsonp I have to find another way to solve this.



AFAIK, MusicBrainz does already allow all CORS requests, so you might go ahead wit JSON.


You’re right, just tried and a request to… returns a
Access-Control-Allow-Origin: "*"
header. So I don’t understand tum1964’s problem.



A json returns the structure as an hierarchy, as you would expect with json.

A jsonp (json procedure) returns the structure in a single string and calls a processing procedure with it.
So a jsonp should return a differently formatted text.
I can give an example with the bandsintown api:

Without jsonp:
“id”: 11289438,

same request with jsonp (activated via &callback=jsonProc
“id”: 11289438,

As you can see the entire hierarchy is contained within function call jsonProc ().
I need this for an ajax call, just returning the json hierarchy does not work.

And I need the ajax call to avoid CORS. Maybe that Musicbrainz handles CORS requests internally ok, but since I already fired requests to other api’s this is not enough.

So I think i still need jsonp for musicbrainz, but MB does not react to the callback option.



As far as I know, JSONP support is no longer sought after but, as @docdem has checked it, CORS is allowed, no doubt. You don’t need to avoid it.

I saw this in the response, me too:

Access-Control-Allow-Origin: *

I tried a random &fmt=json request from a random domain:

var xhr = new XMLHttpRequest();"get", "", false);


GET /ws/2/release/8152e1c7-d737-488c-a02b-a3ef10104580?inc=artists+labels+recordings+release-groups+media+artist-credits+annotation+url-rels&fmt=json HTTP/1.1
User-Agent: Opera/9.80 (Windows NT 5.1) Presto/2.12.388 Version/12.18
Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Language: fr,en;q=0.9,vi;q=0.8,ja;q=0.7
Accept-Encoding: gzip, deflate
Connection: Keep-Alive


HTTP/1.1 200 OK
Date: Tue, 19 Apr 2016 16:32:09 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Keep-Alive: timeout=15
Server: nginx/1.4.6 (Ubuntu)
Access-Control-Allow-Origin: *
Content-Encoding: gzip

{"I am shortening": "the results, here ;)"}

You can manage the response in an event listener:

xhr.addEventListener("load", …
xhr.addEventListener("error", …

You can check many examples like RECORDING_LENGTH_COLUMN in SUPER TURBO (current version).

Consider this error event listener, it took me about 10 503 errors before my first 200 OK.

It’s a little different but it’s still a function that you can write as you wish… no ?


MusicBrainz does, to the best of my knowledge, not support JSONP. We have a JSON web service and all entity pages have embedded JSON-LD (check source code of David Rovics for example).


For the record, I have found it back, where JSONP support was declined, for good reasons: MBS-4057.