Kodi Community Forum

Full Version: Expose a function of my service to JSonRPC
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone, just joined forum and I am a newbie so hope this makes sense:

I'm building a service add-on in python for kodi and I would like to expose an "api" to JSONRPC in order to have other add ons to call my api functions.

I tried to search online but I can only find how to access to other jsonrpc "api's" as a client (JSON-RPC_API/Examples (wiki)) but I can't find out how to expose my functions for others to access.

Thanks for your help.
I figured out the solution:

1) I just need to add this line at my service addon.xml file and then it's ready to role:

<extension point="xbmc.python.pluginsource" library="service.py" />


2) to make the call you can use in the skin or eventually using executebuiltin command in your python file:
plugin://script.service.myservice?action=getPlaylist

3) and then receive and threat this call in the service.py where the get arguments are received as arguments (argv) in the service.py:
xbmc.log("[Started Service in API_MODE] > SYS %s : %d : %d" % (sys.argv, len(sys.argv), os.getpid()), level=xbmc.LOGNOTICE)