Feature: REST API refactoring

Your opinion is very appreciated!

what's your opinion?

That's hot, i like it!
5
100%
Yes, but not need it!
0
No votes
Maybe later.
0
No votes
Better not.
0
No votes
 
Total votes : 5

Feature: REST API refactoring

Unread postby Madevil » 07 Sep 2015, 15:33

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=admin&p=admin&v=1.13.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=admin&p=admin&v=2.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"/>
User avatar
Madevil
Administrator
Administrator
 
Posts: 880
Joined: 07 Dec 2012, 03:58
Has thanked: 1280 times
Been thanked: 946 times

Re: Feature: REST API refactoring

Unread postby daneren2005 » 07 Sep 2015, 23:41

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.
daneren2005
Developer
Developer
 
Posts: 23
Joined: 03 Jan 2014, 00:20
Has thanked: 2 times
Been thanked: 11 times

Re: Feature: REST API refactoring

Unread postby Madevil » 08 Sep 2015, 10:29

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=admin&p=admin&v=1.0.0&c=rest&f=xml
http://localhost:4040/rest/ping.view?u=admin&p=enc:61646d696e&v=1.10.0&c=rest&f=xml
http://localhost:4040/rest/ping.view?u=admin&t=abf0abaeeb6ac8328828576c64c8cc2a&s=xfhn8gf4gv&v=1.13.0&c=rest&f=xml

Madsonic native REST 2.0.0 service

http://localhost:4040/rest2/ping.view?u=admin&p=admin&v=2.0.0&c=rest&f=xml
http://localhost:4040/rest2/ping.view?u=admin&p=enc:61646d696e&v=2.0.0&c=rest&f=xml
http://localhost:4040/rest2/ping.view?u=admin&t=abf0abaeeb6ac8328828576c64c8cc2a&s=xfhn8gf4gv&v=2.0.0&c=rest&f=xml

Example with difference

http://localhost:4040/rest/getGenres.view?u=admin&p=admin&v=1.13.0&c=rest&f=xml
http://localhost:4040/rest2/getGenres.view?u=admin&p=admin&v=2.0.0&c=rest&f=xml

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

http://localhost:4040/rest/ping.view?u=admin&p=admin&v=2.0.0&c=rest&f=json
http://localhost:4040/rest2/ping.view?u=admin&p=admin&v=1.13.0&c=rest&f=json

recommended use

http://localhost:4040/rest/ping.view?u=admin&p=admin&v=1.8.0&c=rest&f=xml
http://localhost:4040/rest2/ping.view?u=admin&p=admin&v=2.0.0&c=rest&f=xml

Online demo test

http://demo.madsonic.org/rest/ping.view?u=demo-guest&p=enc:4d4064246f6e696344656d6f&v=1.13.0&c=rest&f=xml
http://demo.madsonic.org/rest2/ping.view?u=demo-guest&p=enc:4d4064246f6e696344656d6f&v=2.0.0&c=rest&f=xml

http://demo.madsonic.org/rest/getGenres.view?u=demo-guest&p=enc:4d4064246f6e696344656d6f&v=1.13.0&c=rest&f=xml
http://demo.madsonic.org/rest2/getGenres.view?u=demo-guest&p=enc:4d4064246f6e696344656d6f&v=2.0.0&c=rest&f=xml

http://demo.madsonic.org/rest/getArtists.view?id=414&u=demo-guest&p=enc:4d4064246f6e696344656d6f&v=1.13.0&c=rest&f=xml
http://demo.madsonic.org/rest2/getArtists.view?id=414&u=demo-guest&p=enc:4d4064246f6e696344656d6f&v=2.0.0&c=rest&f=xml


best regards
User avatar
Madevil
Administrator
Administrator
 
Posts: 880
Joined: 07 Dec 2012, 03:58
Has thanked: 1280 times
Been thanked: 946 times

Re: Feature: REST API refactoring

Unread postby daneren2005 » 09 Sep 2015, 19:12

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.
daneren2005
Developer
Developer
 
Posts: 23
Joined: 03 Jan 2014, 00:20
Has thanked: 2 times
Been thanked: 11 times

Re: Feature: REST API refactoring

Unread postby Madevil » 13 Sep 2015, 22:38

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
User avatar
Madevil
Administrator
Administrator
 
Posts: 880
Joined: 07 Dec 2012, 03:58
Has thanked: 1280 times
Been thanked: 946 times


Return to Development Voting Polls

Who is online

Users browsing this forum: No registered users and 1 guest