Kodi Community Forum
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174)
+---- Thread: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC (/showthread.php?tid=68263)



- Montellese - 2011-05-28

Mindzai Wrote:I'm sure this must have been asked but my searching hasn't turned up the answer. Where can I find details of the available fields for methods such as VideoLibrary.GetTVShowDetails and VideoLibrary.GetEpisodeDetails please? I notice the GetMovieDetails fields are listed in the wiki but not most other methods.

Thanks Smile

Call JSONRPC.Introspect and study the answer. You will find all the available fields for the different methods there. If you don't know JSON schema yet (which is what JSONRPC.Introspect returns) this might help you understand better what you get back: http://tools.ietf.org/html/draft-zyp-json-schema-03


- Mindzai - 2011-05-28

Montellese Wrote:Call JSONRPC.Introspect and study the answer. You will find all the available fields for the different methods there. If you don't know JSON schema yet (which is what JSONRPC.Introspect returns) this might help you understand better what you get back: http://tools.ietf.org/html/draft-zyp-json-schema-03

I see, thanks for the help. I had tried introspecting but expected the parameters to be listed along with the method. I see that the parameter objects have their own section in the schema which I missed before.


Sort order - Mizaki - 2011-05-29

Sort order desending doesn't appear to work.
Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "sort": { "order": "descending" }, "limits": { "end": 10 } }, "id": 1}
The more basic:
Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "sort": { "order": "descending" }}, "id": 1}
Returns the same as:
Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "sort": { "order": "ascending" }}, "id": 1}

Or am I misunderstanding something?


- Montellese - 2011-05-29

Mizaki Wrote:I've looked around and no one seems to have mentioned it. Something like:

RecentlyAddedAlbums
RecentlyAddedArtists
RecentlyAddedSongs

Is this planned?
Feel free to create feature request tickets for those on trac. I think we once discussed it internally but we couldn't agree on what RecentlyAddedSongs should return because if you e.g. add two new albums and RecentlyAddedSongs only returns 10 songs you will only get the 10 last songs from the last album added.

Mizaki Wrote:Sort order desending doesn't appear to work.
Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "sort": { "order": "descending" }, "limits": { "end": 10 } }, "id": 1}
The more basic:
Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "sort": { "order": "descending" }}, "id": 1}
Returns the same as:
Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "sort": { "order": "ascending" }}, "id": 1}

Or am I misunderstanding something?

You are missing the "sort method". The default method is "none" and if there is no sort ordering you can't really invert the order either. If you e.g. use the sort method "album" or "year" and change between "descending" and "ascending" order you will see a difference.


- Mizaki - 2011-05-30

Okay, I've added a request http://trac.xbmc.org/ticket/11594

As you probably guessed I was trying to get around the lack of recently added.

I see what you are saying but although I'm not specifying a method currently the method of "none" returns the albums in id order, acsending. Albumid is not a valid method for sort, so I was expecting, with the use of desending, the albums to be returned in desending order by albumid.

I would suggest that either the id (albumid, movieid etc.) be allowed in the sort method or that desending with none returns the items in reverse id order.

I realise that "none" should mean none but I can't see another way to get the items in reverse id order?


- vikjon0 - 2011-06-05

topfs2 Wrote:If you give the outside world access to your mysql it is your setup not XBMC which gives access to it. The same if you give remote access to the sqldb file, its a big difference between YOU giving remote programs all access to the database and XBMC ALWAYS giving all access to the database. JSONRPC gives access based on what the client requests and on a per client basis, so a nfo editor may change the data but your phone may only read.

Also you should not assume it will either be sqlite or mysql, there have been talks about switching to other databases before and is something which is a likely scenario. Besides, forcing a client to write both for sqlite and mysql has been shown problematic (the differences are small but they are there). If you force a client to also write to couchdb or whatever because we switch to it for eden, it just becomes unmanageable. Why should the client _need_ to care for it, makes no sense.

You may use it for now but it is clear that giving full access to the database is not future proof, there is no room for arguing on that point. It is deprecated and will at some point be removed. If you wish to give full access to your mysql or sqlitedb file, this is your choice.

Cheers,
Tobias


I totally understand the approach but will you support at least readonly SQL queries when the http api is removed? There will always be something missing and while adding it to the new api is the way to go that means quite some lead time if you develop add-ons for existing stable.

Assuming sql is only used while waiting for the next stable, changes to db model is not an issue since the code is only meant to be used in one version before being replaced with a api call.


- topfs2 - 2011-06-05

vikjon0 Wrote:I totally understand the approach but will you support at least readonly SQL queries when the http api is removed? There will always be something missing and while adding it to the new api is the way to go that means quite some lead time if you develop add-ons for existing stable.

Assuming sql is only used while waiting for the next stable, changes to db model is not an issue since the code is only meant to be used in one version before being replaced with a api call.

No, if your missing something feature request it and we will add it proper instead. No point in allowing hacks, all that will do is make people reluctant to feature request.

EDIT: And I doubt we will disable httpapi in eden, if anything eden will be the last it is available in, but it won't be just disabled until one stable after we deprecate, now its only on will-be-deprecated basis Smile


- vikjon0 - 2011-06-05

topfs2 Wrote:No, if your missing something feature request it and we will add it proper instead. No point in allowing hacks, all that will do is make people reluctant to feature request.

Yes, allowing hack will most likely have that effect.

So basically if I miss something for an add-on I log a request (or make a patch) and push the add-on to next stable?
How isolated is the api? Could it be an option in the future to release the api interface more frequently than core?

I guess one could just make a hack un-official add-on and clean it upp next stable.


- mzanetti - 2011-06-05

I'm getting different character sets in responses to *Library.Get* calls. For example "label" seems to be encoded with UTF8, while "file" seems to be encoded with latin1. This is an example snippet of a response to Library.GetSongs():
Code:
...
{"file":"/home/micha/Music/Die Fantastischen Vier/Fornika/02 Ernten Was Wir Säen.mp3","label":"Ernten Was Wir Säen","songid":49},
...
Note the German Umlaut in the file ("Säen") and the label ("Säen") which should be the same.

Is this intentional or should I file a bugreport? This makes it difficult to convert the string always appropriate.

Thanks


- topfs2 - 2011-06-05

vikjon0 Wrote:Yes, allowing hack will most likely have that effect.

So basically if I miss something for an add-on I log a request (or make a patch) and push the add-on to next stable?
How isolated is the api? Could it be an option in the future to release the api interface more frequently than core?

I guess one could just make a hack un-official add-on and clean it upp next stable.

yup. Generally me and montellese discuss a lot and we have quite a clear roadmap what we want changed til next stable. We haven't really pushed the roadmap pubblic though as we can't really promise anything Smile

In any event, if you miss something make us knowing and we will try to get it in to next release. If you can make patches to core that would be even more appreciated. Its kindof like with skin changes, we try to keep a log about what has changed so users of the API can stay up to date during the dev cycle. We will freeze the API quite some time before a stable to have addon creators time to adjust.

Cheers,
TObias


- billylg - 2011-06-07

Hi Newbie here,
Got a question on using Json RPC. I am trying to figure out how to make JSON RPC calls for a project. I am using the Simple REST client on chrome to test the request and response. I could quite figure out how to get audio playing. The request I sent is the following:

{ "jsonrpc": "2.0", "method": "XBMC.Play", "params": {"name": "C:\music.mp3", type: "audio"}, "id": 1 }

And the response I got back is:

{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}

Can someone tell me what I am doing wrong? Thanks for the help!


- mzanetti - 2011-06-07

billylg Wrote:Hi Newbie here,
Got a question on using Json RPC. I am trying to figure out how to make JSON RPC calls for a project. I am using the Simple REST client on chrome to test the request and response. I could quite figure out how to get audio playing. The request I sent is the following:

{ "jsonrpc": "2.0", "method": "XBMC.Play", "params": {"name": "C:\music.mp3", type: "audio"}, "id": 1 }

And the response I got back is:

{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}

Can someone tell me what I am doing wrong? Thanks for the help!

You have to use AudioPlaylist.Add to add your song items. After that you may use AudioPlaylist.Play with an index in that playlist.


- Montellese - 2011-06-07

billylg Wrote:Hi Newbie here,
Got a question on using Json RPC. I am trying to figure out how to make JSON RPC calls for a project. I am using the Simple REST client on chrome to test the request and response. I could quite figure out how to get audio playing. The request I sent is the following:

{ "jsonrpc": "2.0", "method": "XBMC.Play", "params": {"name": "C:\music.mp3", type: "audio"}, "id": 1 }

And the response I got back is:

{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}

Can someone tell me what I am doing wrong? Thanks for the help!

"Parse error" indicates, that the json object of your request is not valid. A good place to check your syntax is http://www.jsonlint.com
In this particular case the problem is the backslash in your path which is used as an escape character so you need to add another one in front of it (\\) to escape it.

Hope this helped.


- Manromen - 2011-06-07

Does something changed for the recent linux nightly builds (20110606)?
We have a Trakt Utilities addon user reporting issues with the following call not returning a tvshowid:

{'jsonrpc': '2.0', 'method': 'VideoLibrary.GetTVShows','params':{'fields': ['title', 'year', 'imdbnumber', 'playcount']}, 'id': 1}

Edit:
He uses a mysql database.


- Montellese - 2011-06-07

Manromen Wrote:Does something changed for the recent linux nightly builds (20110606)?
We have a Trakt Utilities addon user reporting issues with the following call not returning a tvshowid:

{'jsonrpc': '2.0', 'method': 'VideoLibrary.GetTVShows','params':{'fields': ['title', 'year', 'imdbnumber', 'playcount']}, 'id': 1}

Edit:
He uses a mysql database.

Works for me on latest nightly and nothing in that area changed but I'm on Windows and I don't use mysql.