Page 1 of 1

Feature: REST API refactoring

Posted: 07 Sep 2015, 15:33
by Madsonic
FEATURE:

REST API 2.0

Version 2.0 of the REST API implies the Subsonic protocol.

to make it more backwards compatibly

* add new security layer and inteceptors
* native support of the Subsonic REST API 5.3


Example:

http://localhost:4040/rest/ping.view?u= ... 3.0&c=rest

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.13.0"/>


http://localhost:4040/rest2/ping.view?u ... 0.0&c=rest

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<madsonic-response xmlns="http://madsonic.org/restapi" status="ok" version="2.0.0"/>

Re: Feature: REST API refactoring

Posted: 07 Sep 2015, 23:41
by daneren2005
I like it, BUT can you add something else such as madsonic="2.0.0" so I know that I can also use 2.0.0. Otherwise I will run the first test and it will return 1.13.0 and I will just continue on ignoring the newer API version.

Re: Feature: REST API refactoring

Posted: 08 Sep 2015, 10:29
by Madsonic
with Madsonic 6.0 default installation build >7300

environment

host: localhost
port: 4040
user: admin
password: admin
secret: xfhn8gf4gv
token: md5("admin" + "xfhn8gf4gv") = abf0abaeeb6ac8328828576c64c8cc2a&s

REST API SYNTAX

Code: Select all

SUBSONIC REST: 1.13.0 <SERVER>:<PORT>/REST/<API-METHODE>/?<ARGUMENTS>
MADSONIC REST: 2.0.0  <SERVER>:<PORT>/REST2/<API-METHODE>/?<<ARGUMENTS>
return

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.13.0" type="subsonic"/>

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<madsonic-response xmlns="http://madsonic.org/restapi" status="ok" version="2.0.0" type="madsonic"/>

Subsonic REST 1.13.0 emulator service

http://localhost:4040/rest/ping.view?u= ... rest&f=xml
http://localhost:4040/rest/ping.view?u= ... rest&f=xml
http://localhost:4040/rest/ping.view?u= ... rest&f=xml

Madsonic native REST 2.0.0 service

http://localhost:4040/rest2/ping.view?u ... rest&f=xml
http://localhost:4040/rest2/ping.view?u ... rest&f=xml
http://localhost:4040/rest2/ping.view?u ... rest&f=xml

Example with difference

http://localhost:4040/rest/getGenres.vi ... rest&f=xml
http://localhost:4040/rest2/getGenres.v ... rest&f=xml

will fail: wrong version against server (don't use)

http://localhost:4040/rest/ping.view?u= ... est&f=json
http://localhost:4040/rest2/ping.view?u ... est&f=json

recommended use

http://localhost:4040/rest/ping.view?u= ... rest&f=xml
http://localhost:4040/rest2/ping.view?u ... rest&f=xml

Online demo test

http://demo.madsonic.org/rest/ping.view ... rest&f=xml
http://demo.madsonic.org/rest2/ping.vie ... rest&f=xml

http://demo.madsonic.org/rest/getGenres ... rest&f=xml
http://demo.madsonic.org/rest2/getGenre ... rest&f=xml

http://demo.madsonic.org/rest/getArtist ... rest&f=xml
http://demo.madsonic.org/rest2/getArtis ... rest&f=xml


best regards

Re: Feature: REST API refactoring

Posted: 09 Sep 2015, 19:12
by daneren2005
With that I have no way of knowing that I can switch to using the 2.0 API for Madsonic. By default I will send a request saying that the app requires a min of 1.2. It will then respond with saying that it is subsonic and the version is 1.13. I will have no way of knowing that it is a Madsonic server and I can switch to 2.0. In the first response some sort of madsonic-version would be nice so I can key onto that and use it.

Re: Feature: REST API refactoring

Posted: 13 Sep 2015, 22:38
by Madsonic
daneren2005 wrote:With that I have no way of knowing that I can switch to using the 2.0 API for Madsonic. By default I will send a request saying that the app requires a min of 1.2. It will then respond with saying that it is subsonic and the version is 1.13. I will have no way of knowing that it is a Madsonic server and I can switch to 2.0. In the first response some sort of madsonic-version would be nice so I can key onto that and use it.

Hi Scott,

i saw the same problems with the madsonic client, so i changed some things that help API clients to communicate with the server.

http://beta.madsonic.org/pages/api.jsp#Implementation

http://beta.madsonic.org/pages/api.jsp#getApi

PS: comes with next build

best regards