Kodi Community Forum

Full Version: JavaScript / NodeJS JSON-RPC Wrapper
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I recently spent a couple of hours writing a nodejs module, which should make controlling xbmc via its jsonrpc api pretty easy.
It is still missing some features, like downloading art from xbmc (as it currently only uses websockets), but it has support for all JSONRPC methods and notifications.
It supports client side typechecking based on the schema returned from JSONRPC.Introspect.

You can find the work here:
https://github.com/PaulAvery/xbmc-ws

All it takes to use this is explained in the readme, but it basically looks like this:

Code:
var xbmc = require('xbmc-ws');
var connection = xbmc('your-hostname', 9090);
connection.run('VideoLibrary.GetMovies')(['title', 'rating', 'year'], {"start" : 0, "end": 2}, handler);
connection.close();

The above code opens a new connection to an xbmc installation, queries it for movies and then closes the connection once done.
Once the query is finished, the handler function is called with the result of the rpc response.

Features I am looking to implement now are support for easy loading of images via http and the ability to use this in a browser.

I hope this is of use to some of you, I would love to hear some feedback on this and any suggestions are always welcome

Update:
This is now usable in the browser, so any potential authors of web-interfaces can use this for easy querying of xbmc.