• 1
  • 11
  • 12
  • 13(current)
  • 14
  • 15
Working JSON RPC API Examples
(2019-11-16, 08:00)IT007 Wrote: Thanks, looks a bit cleaner that what I came up with. I use logitech harmony and needed this for the power off command to stop kodi playback before exiting.
No problem.  I also use a Logitech Harmony for controlling Kodi, etc.
Reply
(2018-09-23, 19:48)iophobia Wrote: Don't know where to put this but hope somebody can help.

As of Kodi 17 I used to invoke Alexa --> IFTTT --> Kodi JSON-RPC to change PVR channels in Kodi via HTTP GET and "http://URL/jsonrpc?request={ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "channelid": 5} }, "id": 3 }" which worked liked a charme. I understand that the API changes in v18 don't allow for "GET" but I simply have no idea how a working example for the v18 API would look like for my case.

Thanks in advance.
Anybody managed to get Player.Open to work via IFTTT in Kodi 18? I don't wanna mess around with (my)OpenHAB implementations or such if it can be done in an easier way that already worked in v17.
Reply
(2019-12-18, 15:41)iophobia Wrote:
(2018-09-23, 19:48)iophobia Wrote: Don't know where to put this but hope somebody can help.

As of Kodi 17 I used to invoke Alexa --> IFTTT --> Kodi JSON-RPC to change PVR channels in Kodi via HTTP GET and "http://URL/jsonrpc?request={ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "channelid": 5} }, "id": 3 }" which worked liked a charme. I understand that the API changes in v18 don't allow for "GET" but I simply have no idea how a working example for the v18 API would look like for my case.

Thanks in advance.
Anybody managed to get Player.Open to work via IFTTT in Kodi 18? I don't wanna mess around with (my)OpenHAB implementations or such if it can be done in an easier way that already worked in v17. 

I also have the same exact issue.  It's one of the reasons why I haven't upgraded to Kodi 18.  I use Cortana --> IFTTT --> EventGhost --> Kodi JSON-RPC on Kodi 17.6 (DSPlayer build).  If you (or anyone) figures it out, PLEASE post here.  I will also do the same.
Reply
how to shutdown kodi using request from external server?
when was a normal version of kodi I used this url
Quote:getURL('http://192.168.1.12:8080/jsonrpc?request={"jsonrpc":"2.0","method":"System.Shutdown","id":1}');
Reply
Can anyone give me a working example of subscribing to notifications?

When I pass this:
json:
{"jsonrpc": "2.0", "method": "Configuration.Notifications", "id": 1}

I get this:
json:
{"error":{"code":-32601,"message":"Method not found."},"id":1,"jsonrpc":"2.0"}
Reply
(2020-05-22, 05:20)madkat Wrote: Can anyone give me a working example of subscribing to notifications?

When I pass this:
json:
{"jsonrpc": "2.0", "method": "Configuration.Notifications", "id": 1}

I get this:
json:
{"error":{"code":-32601,"message":"Method not found."},"id":1,"jsonrpc":"2.0"}
Scratch that, I'm getting somewhere now:

json:
{"jsonrpc": "2.0", "method": "JSONRPC.SetConfiguration", "params": {"Configuration.Notifications": { "PVR": true, "Player": true }}, "id": 1}
Reply
(2020-05-22, 05:25)madkat Wrote:
(2020-05-22, 05:20)madkat Wrote: Can anyone give me a working example of subscribing to notifications?

When I pass this:
json:
{"jsonrpc": "2.0", "method": "Configuration.Notifications", "id": 1}

I get this:
json:
{"error":{"code":-32601,"message":"Method not found."},"id":1,"jsonrpc":"2.0"}
Scratch that, I'm getting somewhere now:

json:
{"jsonrpc": "2.0", "method": "JSONRPC.SetConfiguration", "params": {"Configuration.Notifications": { "PVR": true, "Player": true }}, "id": 1}
 
I'm not seeing any notifications though...? (Connected via TCP)
Reply
(2020-05-22, 14:24)madkat Wrote:
(2020-05-22, 05:25)madkat Wrote:
(2020-05-22, 05:20)madkat Wrote: Can anyone give me a working example of subscribing to notifications?

When I pass this:
json:
{"jsonrpc": "2.0", "method": "Configuration.Notifications", "id": 1}

I get this:
json:
{"error":{"code":-32601,"message":"Method not found."},"id":1,"jsonrpc":"2.0"}
Scratch that, I'm getting somewhere now:

json:
{"jsonrpc": "2.0", "method": "JSONRPC.SetConfiguration", "params": {"Configuration.Notifications": { "PVR": true, "Player": true }}, "id": 1}
 
I'm not seeing any notifications though...? (Connected via TCP) 

I am seeing notifications - e.g. play/pause.

New problem with Live TV: I pass this method invocation:
json:
{"jsonrpc": "2.0", "method": "Player.GetProperties", "params":{"playerid":1,"properties":["totaltime","time"]}, "id": 1}

And I get back a perfectly sensible reply:
json:
{"id":1,"jsonrpc":"2.0","result":{"time":{"hours":0,"milliseconds":0,"minutes":40,"seconds":11},"totaltime":{"hours":1,"milliseconds":
0,"minutes":0,"seconds":0}}}

However, the "time" is the time of the stream, not the time of the playing programme - if I pause, the "time" returned continues to increase. Do I need to do something with the PVR to get the state information I'm looking for?
Reply
Hi,

I would like to launch a addon from a remote server.

i found this but didn't work, can you show me a example how to launch a addon ?

http://192.168.1.10/jsonrpc?request={%22...2params%22:[{%22addonid%22:%22script.securitycam%22}:
,%22id%22:%221%22}]
Reply
(2020-07-24, 19:45)karlzre Wrote: Hi,

I would like to launch a addon from a remote server.

i found this but didn't work, can you show me a example how to launch a addon ?

http://192.168.1.10/jsonrpc?request={%22...2params%22:[{%22addonid%22:%22script.securitycam%22}:
,%22id%22:%221%22}]

Your message doesn't display properly. Are you on a Mac? I'm asking due to all the "%22" references in your URL. They should be spaces.

You must send a RESTful command to your Kodi's HTTP server address. IIRC, Kodi 16 and earlier requires a GET command. Kodi 17+ uses POST.

Instructions using command line/CURL/BaSH formatting found here.
Headless Linux Kodi box [Ubuntu 16.04.6 LTS Server] | Dedicated Media Server [Ubuntu 16.04.6 LTS Server]
Reply
Can any one tell me if its possible to combine these into one command,
{"jsonrpc": "2.0", "method": "Player.GetProperties", "params": { "properties": ["currentaudiostream", "percentage", "totaltime", "speed"], "playerid": 1 }, "id": "VideoGetItem"}

and

{"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": ["title", "thumbnail"], "playerid": 1 }, "id": "1"}

thanks
Reply
(2020-08-02, 06:33)mpg732 Wrote: Can any one tell me if its possible to combine these into one command,
{"jsonrpc": "2.0", "method": "Player.GetProperties", "params": { "properties": ["currentaudiostream", "percentage", "totaltime", "speed"], "playerid": 1 }, "id": "VideoGetItem"}

and

{"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": ["title", "thumbnail"], "playerid": 1 }, "id": "1"}

thanks
Sry, that's not possible.
Reply
Sorry for cross-posting....Mods, please feel free to delete my original post. This thread seems more relevant than the one where I posted originally.

Onward....

I run my own self hosted web page where I admin many of my home server items. While not an expert, for years I muddled through figuring out how to do things. I created this page in php. One of the many things I was able to do, were Video and Music Library Updates.

Leia simply killed this feature (and others). I did not realize this until I upgraded from Krypton.

Without luck, I have tried for many many hours, to execute the curl command that performs this action in PHP:

curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "mybash"}' -H 'content-type: application/json;' http://kodi:[email protected]:80/jsonrpc

Would some kind soul please guide me to make php execute the above curl command... every sample I have seen includes "options, arrays, things" that I cannot relate to the line above. Figuring this out will allow me to also update a few other bits that my page did.

I have grown accustomed executing many Kodi commands with the old API method. I have Kodi on a couple of Intel NUC's running LibreElec.


Thank you in advance.

H.
Image
Reply
Answering my own question above.... I would have NEVER figured this out until I ran into a web site that does Curl to PHO conversion.

https://incarnate.github.io/curl-to-php/

I entered:
curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "mybash"}' -H 'content-type: application/json;' http://kodi:[email protected]:80/jsonrpc

and it output this:
php:
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://kodi:[email protected]:80/jsonrpc');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{ \"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.Scan\", \"params\":{\"directory\":\"smb://TOWER/Media/Music Shows/\"}, \"id\": \"mybash\"}");

$headers = array();
$headers[] = 'Content-Type: application/json;';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);

It works like a charm... I was able to tweak things to adapt to my needs.

I hope this helps someone. I found that site purely by luck.

Thanks,

H.
Image
Reply
(2020-08-09, 02:12)hernandito Wrote: and it output this:

Did you know that this forum has color-syntax support? Smile
Reply
  • 1
  • 11
  • 12
  • 13(current)
  • 14
  • 15

Logout Mark Read Team Forum Stats Members Help
Working JSON RPC API Examples0