JSON-RPC API: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Topfs2
No edit summary
 
(171 intermediate revisions by 27 users not shown)
Line 1: Line 1:
== Overview ==
{{JSON-RPC_API_nav}}
JSON RPC is a HTTP-based or raw TCP Socket interface for communicating with XBMC. It replaces the soon-to-be-depreceated HTTP API, and offers a more secure and robust mechanism in the same format. It is based upon the [http://groups.google.com/group/json-rpc/web/json-rpc-2-0?pli=1 JSON RPC 2.0 specification].
{{mininav|[[Development]]}}


Each method in the interface can have different security needs which means one client may be allowed to only control playback while another can only read and manipulate the library. In version 2 (first stable) all clients are granted full authority but will later be forced to ask for privileges and the user of XBMC will have to grant said client access. The design of JSON RPC is that most methods should behave roughly the same and maintain consistency while hiding the mechanics of XBMC from the client creator.


In XBMC JSON RPC can be accessed over a variety of transports and has been designed from the ground up to be flexible to allow control over new transports simply. Some of the transports have different limitations which will be enforced upon the interaction over that transport. As an example HTTP Transports allow response and downloading of files while the Raw TCP Transport allows response and announcements (events and information XBMC sends to its clients). Depending on the clients needs it will choose one (or many) of the transports.


== Enabling JSON RPC ==
JSON-RPC is a HTTP- and/or raw TCP socket-based interface for communicating with Kodi. It replaces the deprecated HTTP API, and offers a more secure and robust mechanism in the same format. It is based upon the [http://jsonrpc.org/spec.html JSON-RPC 2.0 specification].
Since the interface is available on many transports enabling it will depends on the transport.
* Python. Always enabled
* HTTP. Enable webserver
* TCP. "Allow External Control of XBMC" for localhost control and "Allow Control from other computers" for access from outside localhost.


Note: The EventServer is a different interface for sending remote keypresses to XBMC, and must be enabled separately, some programs may use both interfaces.
Each method in the interface can have different security needs which means one client may be allowed to only control playback while another can only read and manipulate the library. In version 2 (first stable) and 4 all clients are granted full authority but will later be forced to ask for privileges and the user of Kodi will have to grant said client access. The design of JSON-RPC is that most methods should behave roughly the same and maintain consistency while hiding the mechanics of Kodi from the client creator.


== XBMC API ==
In Kodi JSON-RPC can be accessed over a variety of transports and has been designed from the ground up to be flexible to allow control over new transports easily. Some of the transports have different limitations which will be enforced upon the interaction over that transport. As an example HTTP transports allow response and downloading of files while the raw TCP transport allows response and notifications (events and information Kodi sends to its clients). Depending on the client's needs it will choose one (or many) of the available transports.<br />
The XBMC JSON api is split up into namespaces, which contain methods that can be called. These namespaces are:
<pre>
JSONRPC          A variety of standard JSONRPC calls
Player          Manages all available players
AudioPlayer      Audio playback control
VideoPlayer      Video playback control
Slideshow        Picture playback control
Playlist        Playlist Modification
Files            Shares information
AudioLibrary    Audio Library Information
VideoLibrary    Video Library Information
System          System Controls and Information
XBMC            Application controls
</pre>


== JSONRPC ==
=== JSONRPC.Introspect ===
Returns a list of all available method calls
<pre>
PARAMETERS
getpermissions    boolean    OPTIONAL: return list of required permissions
getdescriptions    boolean    OPTIONAL: return list of method descriptions
filterbytransport  boolean    OPTIONAL: Return only methods available on this transport
</pre>


=== JSONRPC.Version ===
== Enabling JSON-RPC ==
Returns the version of this API (not JSONRPC version). An even number refers to a stable version while odd number is development.
Since the interface is available on many transports enabling it depends on the transport.
* Python: Always enabled
* HTTP: In System/Settings/Network/Services activate ''Allow control of Kodi via HTTP'' (see [[Webserver#Enabling_the_webserver|Enabling the webserver]])
* TCP: In System/Settings/Network/Services activate ''Allow programs on this system to control Kodi'' for localhost access only and ''Allow programs on other systems to control Kodi'' for access from other computers as well


=== JSONRPC.Permission ===
Note: The [[EventServer]] is a different interface for sending remote keypresses to Kodi, and must be enabled separately, some programs may use both interfaces.
Returns a list of client permissions


=== JSONRPC.Ping ===
== Transports & Functionalities ==
Returns pong!
=== Transports ===
==== Python ====
The ''Python'' transport can only be used by Kodi addons through the '''executeJSONRPC''' method provided by the '''xbmc''' python library. As it must be available to every addon in an Kodi installation it must not be enabled or disabled by the user.


=== JSONRPC.GetAnnouncementFlags ===
==== HTTP ====
Returns what announcements the client is listening for
The ''HTTP'' transport can be used by third-party applications running on the same machine as Kodi or on a different machine which can access the machine running Kodi using the [http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol HTTP] protocol. Because this transport allows applications outside Kodi to control Kodi, it has to be manually enabled (see [[#Enabling JSON-RPC|Enabling JSON-RPC]]) by the user.


=== JSONRPC.SetAnnouncementFlags ===
===== POST =====
Sets what announcements the client is listening for
Third-party applications can access Kodi's JSON-RPC API by sending JSON-RPC requests embedded in HTTP [http://en.wikipedia.org/wiki/POST_(HTTP) POST] requests to the following URL
<pre>http://<your-ip>:<your-port>/jsonrpc</pre>


=== JSONRPC.Announce ===
Starting with Frodo nightly builds it is mandatory to set the HTTP header field '''Content-Type: application/json'''
Send a message to other clients. An announcement made by a client will fall under the "Other" announcement category so a client can't pretend to send XBMC messages (which will never send on "Other").
<pre>


PARAMETERS
===== GET =====
sender            string    the sender of the announcement (your client name)
Third-party application can access Kodi's JSON-RPC API by sending JSON-RPC requests embedded in a HTTP GET parameter called ''request''. The JSON-RPC request must be URL encoded and sent to the following URL
message            string    description of the announcement
<pre>http://<your-ip>:<your-port>/jsonrpc?request=<url-encoded-request></pre>
data              object    OPTIONAL: data associated with this message
</pre>


== Player ==
==== TCP ====
=== Player.GetActivePlayers ===
The ''TCP'' transport can be used by third-party applications running on the same machine as Kodi or on a different machine which can access the machine running Kodi using the [http://en.wikipedia.org/wiki/Transmission_Control_Protocol TCP] protocol. Because this transport allows applications outside Kodi to control Kodi it has to be manually enabled (see [[#Enabling JSON-RPC|Enabling JSON-RPC]]) by the user. Once enabled, third-party applications can access Kodi's JSON-RPC API by opening a TCP [http://en.wikipedia.org/wiki/Internet_socket socket] on port 9090 (this port can be configured in the [[Advancedsettings.xml#<jsonrpc>|advanced settings]] file) and sending raw JSON-RPC requests over that socket. Please note that no delimiters are provided in between notifications and/or responses. As such, your client needs to be able to deal with this, eg. by counting and matching curly braces ({}).
Returns which players are active (available for querying)<br />
Note: AudioPlayer, VideoPlayer and Slideshow methods are only available if there respective player is active, use this function to obtain that information
<pre>
RESULT
video              boolean    True if video is available, false otherwise
audio              boolean    True if audio is available, false otherwise
picture            boolean    True if pictures are playing, false otherwise
</pre>


== AudioPlayer ==
==== WebSocket ====
=== AudioPlayer.State ===
The ''WebSocket'' transport has been added since Version 5 and can be used by third-party applications running on the same machine as Kodi or on a different machine which can access the machine running Kodi using the [http://en.wikipedia.org/wiki/WebSocket Websocket] protocol. The supported versions are 8 (draft [http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10 hybi-10]) and 13 ([http://tools.ietf.org/html/rfc6455 RFC 6455]). Because this transport allows applications outside Kodi to control Kodi it has to be manually enabled (see [[#Enabling JSON-RPC|Enabling JSON-RPC]]) by the user. Once enabled, third-party applications can access Kodi's JSON-RPC API by sending a WebSocket protocol handshake to the following URI
Gets the state of the audio player
<pre>ws://<your-ip>:<configured tcp port>/jsonrpc</pre>
<pre>
It is important to send the handshake on the port of Kodi's TCP server (by default 9090, but this port can be configured in the [[Advancedsettings.xml#<jsonrpc>|advanced settings]] file). After having successfully finished the handshake third-party applications can send WebSocket protocl messages over that connection.
RESULT
playing            boolean    True if audio is currently playing
paused            boolean    True if audio is currently paused
partymode          boolean    True if party mode is enabled
</pre>


=== AudioPlayer.PlayPause ===
=== Functionalities ===
Pauses or unpauses playback, returns new state
==== Response ====
<pre>
The ''Response'' functionality is the only functionality that should be present in every transport available as it describes the functionality to respond to a JSON-RPC request with a valid JSON-RPC response (be it an error message or an actual response).
RESULT
playing            boolean    True if audio is currently playing
paused            boolean    True if audio is currently paused
</pre>


=== AudioPlayer.Stop ===
==== Notifications ====
Stops playback
The ''Notifications'' functionality includes both server-side (from the server to clients) and client-side (from clients to the server) notifications. A JSON-RPC notification is a valid JSON-RPC request with no ''id'' property. Following the JSON-RPC 2.0 specification any JSON-RPC request with no ''id'' must be considered as a notification and the receiver must not send a response upon a notification.


=== AudioPlayer.SkipPrevious ===
In the specific case of Kodi, server-side notifications are used to inform clients about certain events to relieve clients of the need to periodically poll for certain events. Furthermore there are two ways of client-side notifications. Using JSONRPC.NotifyAll it is possible to ask Kodi to relay the message in the JSON-RPC request to all other connected clients. The second way is to send JSON-RPC requests without an ''id'' property in case the client does not care about the response (e.g. the method Player.Stop does not return any useful information to the client).
Skips to the previous item in the playlist


=== AudioPlayer.SkipNext ===
==== Direct file download ====
Skips to the next item in the playlist
The ''Direct file download'' functionality is the ability to directly download files from Kodi by calling Files.Download. In this case the term ''direct'' means that the download happens within the JSON-RPC response of the Files.Download request.


=== AudioPlayer.BigSkipBackward ===
==== Redirected file download ====
Skips backward in the current track by a big amount
The ''Redirected file download'' functionality is the ability to indirectly download files from Kodi by calling Files.PrepareDownload and using the data received in the response to download the file over a different protocol (like HTTP, FTP ...) or another socket. As the ''Redirected file download'' is very transport specific, it must be handled separately for every transport supporting it.


=== AudioPlayer.BigSkipForward ===
=== Comparison ===
Skips forward in the current track by a big amount
The following table shows all the available transports and what functionalities they support
{| class="prettytable" style="margin-right: 0;"
!style="padding-left: 5px; padding-right: 10px;" colspan="2"|Transport
!style="padding-left: 10px; padding-right: 10px;"|Response
!style="padding-left: 10px; padding-right: 10px;"|Notifications
!style="padding-left: 10px; padding-right: 10px;"|Direct file<br />download
!style="padding-left: 10px; padding-right: 10px;"|Redirected file<br />download
|-
|style="padding-left: 5px;" colspan="2"|Python
|{{yes}}
|{{no}}
|{{no}}
|{{no}}
|-
|style="padding-left: 5px;" colspan="2"|[http://en.wikipedia.org/wiki/Transmission_Control_Protocol TCP]
|{{yes}}
|{{yes}}
|{{no}}
|{{no}}
|-
|style="padding-left: 5px; padding-right:5px;" rowspan="2"|[http://en.wikipedia.org/wiki/HTTP HTTP]
|style="padding-left: 5px; padding-right:5px;"|POST
|{{yes}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px; padding-right:5px;"|GET<sup>1</sup>
|{{yes}}
|{{no}}
|{{no}}
|{{yes}}
|-
|style="padding-left: 5px;" colspan="2"|[http://en.wikipedia.org/wiki/WebSocket WebSocket]<sup>1</sup>
|{{yes}}
|{{yes}}
|{{no}}
|{{no}}
|-
|}
<sup>1</sup> Added in Version 5


=== AudioPlayer.SmallSkipBackward ===
== API versions ==
Skips backward in the current track by a small amount
The JSON-RPC API exposed by Kodi is constantly extended to provide better and more functionality to third party applications. For that reason Kodi provides a version information through the '''JSONRPC.Version''' method. The rule is that odd version numbers describe an API state, that is not stable and under heavy development whereas even version numbers describe a stable API. Therefore the version number can be used by third-party clients to check if their application might not be fully compatible with the JSON-RPC API exposed by a user's Kodi installation.


=== AudioPlayer.SmallSkipForward ===
Starting with XBMC v12 (Frodo) we started using a new versioning system (<major>.<minor>.<patch>) for the JSON-RPC API. Frodo stable is version 6.0.0 and from now on with every bugfix the <patch> part of the version is increased, with every feature addition to the API, the <minor> version is increased (and the <patch> version reset to 0) and with every backwards incompatible change, the <major> version is increased.
Skips forward in the current track by a small amount


=== AudioPlayer.Rewind ===
{| class="prettytable" style="margin-right: 0;"
Rewind current track
!colspan="3"|Release
!colspan="6"|JSON-RPC 2.0 specification
!colspan="5"|Transports
|-
!style="padding-left: 5px; padding-right: 5px; width: 6em; text-align: left;"|API Version
!style="padding-left: 10px; padding-right: 10px; width: 5em;"|Version
!style="padding-left: 10px; padding-right: 10px; width: 4em;"|Name
!style="padding-left: 10px; padding-right: 10px;"|Method calls
!style="padding-left: 10px; padding-right: 10px;"|Notifications<br />(server-side)
!style="padding-left: 10px; padding-right: 10px;"|Notifications<br />(client-side)
!style="padding-left: 10px; padding-right: 10px;"|Parameters<br />by-name
!style="padding-left: 10px; padding-right: 10px;"|Parameters<br />by-position
!style="padding-left: 10px; padding-right: 10px;"|Batch requests


=== AudioPlayer.Forward ===
!style="padding-left: 10px; padding-right: 10px;"|Python
Play current track forwards (Fast Forwards? unknown)
!style="padding-left: 10px; padding-right: 10px;"|TCP
!style="padding-left: 10px; padding-right: 10px;"|HTTP POST
!style="padding-left: 10px; padding-right: 10px;"|HTTP GET
!style="padding-left: 10px; padding-right: 10px;"|WebSocket
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 2
|style="padding-left: 5px; padding-right: 5px;"|10.0
|style="padding-left: 5px; padding-right: 5px;"|Dharma
|{{yes}}
|{{yes}}
|{{no}}
|{{yes}}
|{{no}}
|{{no}}


=== AudioPlayer.GetTime ===
|{{yes}}
Gets the state of the audio player, including time information, to the second
|{{yes}}
<pre>
|{{yes}}
RESULT
|{{no}}
time              number    Position in current track in seconds
|{{no}}
total              number    Duration of current track in seconds
|-
playing            boolean    True if audio is currently playing
|style="padding-left: 5px; padding-right: 5px;"|Version 3 / 4
paused            boolean    True if audio is currently paused
|style="padding-left: 5px; padding-right: 5px;"|pre-11 / 11.0
</pre>
|style="padding-left: 5px; padding-right: 5px;"|Eden
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== AudioPlayer.GetTime ===
|{{yes}}
Gets the state of the audio player, including time information, to the millisecond
|{{yes}}
<pre>
|{{yes}}
RESULT
|{{no}}
time              number    Position in current track in milliseconds
|{{no}}
total              number    Duration of current track in milliseconds
|-
playing            boolean    True if audio is currently playing
|style="padding-left: 5px; padding-right: 5px;"|Version 5 / 6
paused            boolean    True if audio is currently paused
|style="padding-left: 5px; padding-right: 5px;"|pre-12 / 12.0
</pre>
|style="padding-left: 5px; padding-right: 5px;"|Frodo
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== AudioPlayer.GetPercentage ===
|{{yes}}
Gets a percentage, of what is not obviously documented, presumably Position/Duration*100
|{{yes}}
<pre>
|{{yes}}
RESULT            number    Percentage
|{{yes}}
</pre>
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 6
|style="padding-left: 5px; padding-right: 5px;"|13.0
|style="padding-left: 5px; padding-right: 5px;"|Gotham
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== AudioPlayer.GetPercentage ===
|{{yes}}
Gets a percentage, of what is not obviously documented, presumably Position/Duration*100
|{{yes}}
<pre>
|{{yes}}
RESULT            number    Percentage
|{{yes}}
</pre>
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 6
|style="padding-left: 5px; padding-right: 5px;"|13.1
|style="padding-left: 5px; padding-right: 5px;"|Gotham
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== AudioPlayer.SeekTime ===
|{{yes}}
Seek to a position in the track defined by position in seconds
|{{yes}}
<pre>
|{{yes}}
PARAMETER          number    Position to seek to
|{{yes}}
</pre>
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 6
|style="padding-left: 5px; padding-right: 5px;"|13.2
|style="padding-left: 5px; padding-right: 5px;"|Gotham
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== AudioPlayer.SeekPercentage ===
|{{yes}}
Seek to a position in the track defined by a percentage (of total duration?)
|{{yes}}
<pre>
|{{yes}}
PARAMETER          number    Percentage to seek to
|{{yes}}
</pre>
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 6
|style="padding-left: 5px; padding-right: 5px;"|14.0
|style="padding-left: 5px; padding-right: 5px;"|Helix
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


== VideoPlayer ==
|{{yes}}
VideoPlayer contains exactly the same methods as AudioPlayer, see method in that namespace.
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 6
|style="padding-left: 5px; padding-right: 5px;"|14.1
|style="padding-left: 5px; padding-right: 5px;"|Helix
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


== PicturePlayer ==
|{{yes}}
=== PicturePlayer.PlayPause ===
|{{yes}}
Pauses or unpauses slideshow.
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 6
|style="padding-left: 5px; padding-right: 5px;"|14.2
|style="padding-left: 5px; padding-right: 5px;"|Helix
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== PicturePlayer.Stop ===
|{{yes}}
Stops playback.
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 6
|style="padding-left: 5px; padding-right: 5px;"|15.0
|style="padding-left: 5px; padding-right: 5px;"|Isengard
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== PicturePlayer.SkipPrevious ===
|{{yes}}
Skips to the previous item in the slideshow.
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 6
|style="padding-left: 5px; padding-right: 5px;"|15.1
|style="padding-left: 5px; padding-right: 5px;"|Isengard
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== PicturePlayer.SkipNext ===
|{{yes}}
Skips to the next item in the slideshow.
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 6
|style="padding-left: 5px; padding-right: 5px;"|15.2
|style="padding-left: 5px; padding-right: 5px;"|Isengard
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== PicturePlayer.MoveLeft ===
|{{yes}}
In a zoomed view, pans the viewport to the left.
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 6
|style="padding-left: 5px; padding-right: 5px;"|16.0
|style="padding-left: 5px; padding-right: 5px;"|Jarvis
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== PicturePlayer.MoveRight ===
|{{yes}}
In a zoomed view, pans the viewport to the right.
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 6
|style="padding-left: 5px; padding-right: 5px;"|16.1
|style="padding-left: 5px; padding-right: 5px;"|Jarvis
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== PicturePlayer.MoveDown ===
|{{yes}}
In a zoomed view, pans the viewport downwards.
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 8
|style="padding-left: 5px; padding-right: 5px;"|17.0
|style="padding-left: 5px; padding-right: 5px;"|Krypton
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== PicturePlayer.MoveUp ===
|{{yes}}
In a zoomed view, pans the viewport upwards.
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 10
|style="padding-left: 5px; padding-right: 5px;"|18
|style="padding-left: 5px; padding-right: 5px;"|Leia
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== PicturePlayer.ZoomOut ===
|{{yes}}
Zooms the viewport out.
|{{yes}}
|{{yes}}
|{{yes}}<sup>1</sup>
|{{yes}}
|-
|style="padding-left: 5px; padding-right: 5px;"|Version 12
|style="padding-left: 5px; padding-right: 5px;"|19
|style="padding-left: 5px; padding-right: 5px;"|Matrix
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}
|{{yes}}


=== PicturePlayer.ZoomIn ===
|{{yes}}
Zooms the viewport in.
|{{yes}}
|{{yes}}
|{{yes}}<sup>1</sup>
|{{yes}}
|-
|}
<sup>1</sup>For information requests only, actions require POST


=== PicturePlayer.Zoom ===
{| class="prettytable" style="margin-right: 0;"
Zoom to a defined level
!colspan="3"|Release
<pre>
!|JSONRPC.Version
PARAMETER          number    Zoom level to seek to, as a whole number between 1-10
|-
</pre>
!style="padding-left: 10px; padding-right: 10px;"|Date
!style="padding-left: 10px; padding-right: 10px;"|Version
!style="padding-left: 10px; padding-right: 10px;"|Codename
!style="padding-left: 10px; padding-right: 10px;"|["version"]
|-
|18 December 2010
|10.0
|Dharma
|2
|-
|10 March 2011
|10.1
|Dharma
|2
|-
| style="background:#eee;" |24 March 2012
| style="background:#eee;" |11.0
| style="background:#eee;" |Eden
| style="background:#eee;" |4
|-
|29 January 2013
|12.0
|Frodo
|{"major":6,"minor":0,"patch":0}
|-
|18 March 2013
|12.1
|Frodo
|{"major":6,"minor":0,"patch":3}
|-
|03 May 2013
|12.2
|Frodo
|{"major":6,"minor":0,"patch":3}
|-
|24 December 2013
|12.3
|Frodo
|{"major":6,"minor":0,"patch":3}
|-
| style="background:#eee;" | 04 May 2014
| style="background:#eee;" | 13.0
| style="background:#eee;" | Gotham
| style="background:#eee;" | {"major":6,"minor":14,"patch":3}
|-
| style="background:#eee;" | 05 June 2014
| style="background:#eee;" | 13.1
| style="background:#eee;" | Gotham
| style="background:#eee;" | {"major":6,"minor":14,"patch":3}
|-
| style="background:#eee;" | 17 August 2014
| style="background:#eee;" | 13.2
| style="background:#eee;" | Gotham
| style="background:#eee;" | {"major":6,"minor":14,"patch":3}
|-
|23 December 2014
|14.0
|Helix
|{"major":6,"minor":21,"patch":2}
|-
|30 January 2014
|14.1
|Helix
|{"major":6,"minor":21,"patch":2}
|-
|26 March 2014
|14.2
|Helix
|{"major":6,"minor":21,"patch":2}
|-
| style="background:#eee;" | 21 July 2015
| style="background:#eee;" | 15.0
| style="background:#eee;" | Isengard
| style="background:#eee;" | {"major":6,"minor":25,"patch":2}
|-
| style="background:#eee;" | 16 August 2015
| style="background:#eee;" | 15.1
| style="background:#eee;" | Isengard
| style="background:#eee;" | {"major":6,"minor":25,"patch":2}
|-
| style="background:#eee;" | 19 October 2015
| style="background:#eee;" | 15.2
| style="background:#eee;" | Isengard
| style="background:#eee;" | {"major":6,"minor":25,"patch":2}
|-
|21 February 2016
|16.0
|Jarvis
|{"major":6,"minor":32,"patch":4}
|-
|24 April 2016
|16.1
|Jarvis
|{"major":6,"minor":32,"patch":5}
|-
| style="background:#eee;" | 05 February 2017
| style="background:#eee;" | 17.0
| style="background:#eee;" | Krypton
| style="background:#eee;" | {"major":8,"minor":0,"patch":0}
|-
| style="background:#eee;" | 20 March 2017
| style="background:#eee;" | 17.1
| style="background:#eee;" | Krypton
| style="background:#eee;" | {"major":8,"minor":0,"patch":0}
|-
| style="background:#eee;" | 23 May 2017
| style="background:#eee;" | 17.2
| style="background:#eee;" | Krypton
| style="background:#eee;" | {"major":8,"minor":0,"patch":0}
|-
| style="background:#eee;" | 24 May 2017
| style="background:#eee;" | 17.3
| style="background:#eee;" | Krypton
| style="background:#eee;" | {"major":8,"minor":0,"patch":0}
|-
| style="background:#eee;" | 22 August 2017
| style="background:#eee;" | 17.4
| style="background:#eee;" | Krypton
| style="background:#eee;" | {"major":8,"minor":0,"patch":0}
|-
| style="background:#eee;" | 23 October 2017
| style="background:#eee;" | 17.5
| style="background:#eee;" | Krypton
| style="background:#eee;" | {"major":8,"minor":0,"patch":0}
|-
| style="background:#eee;" | 14 November 2017
| style="background:#eee;" | 17.6
| style="background:#eee;" | Krypton
| style="background:#eee;" | {"major":8,"minor":0,"patch":0}
|-
| 29 January 2019
| 18.0
| Leia
| {"major":10,"minor":1,"patch":1}
|-
| 17 February 2019
| 18.1
| Leia
| {"major":10,"minor":1,"patch":2}
|-
| 22 April 2019
| 18.2
| Leia
| {"major":10,"minor":3,"patch":0}
|-
| 27 June 2019
| 18.3
| Leia
| {"major":10,"minor":3,"patch":0}
|-
| 01 September 2019
| 18.4
| Leia
| {"major":10,"minor":3,"patch":0}
|-
| 17 November 2019
| 18.5
| Leia
| {"major":10,"minor":3,"patch":0}
|-
| 02 March 2020
| 18.6
| Leia
| {"major":10,"minor":3,"patch":0}
|-
| 21 May 2020
| 18.7
| Leia
| {"major":10,"minor":3,"patch":0}
|-
| 01 June 2020
| 18.7.1
| Leia
| {"major":10,"minor":3,"patch":0}
|-
| 14 June 2020
| 18.7.2
| Leia
| {"major":10,"minor":3,"patch":0}
|-
| 29 July 2020
| 18.8
| Leia
| {"major":10,"minor":3,"patch":0}
|-
| 24 October 2020
| 18.9
| Leia
| {"major":10,"minor":3,"patch":0}
|-
| style="background:#eee;" | 20 February 2021
| style="background:#eee;" | 19.0
| style="background:#eee;" | Matrix
| style="background:#eee;" | {"major":12,"minor":2,"patch":1}
|-
| style="background:#eee;" | 10 May 2021
| style="background:#eee;" | 19.1
| style="background:#eee;" | Matrix
| style="background:#eee;" | {"major":12,"minor":3,"patch":0}
|-
| style="background:#eee;" | 09 October 2021
| style="background:#eee;" | 19.2
| style="background:#eee;" | Matrix
| style="background:#eee;" | {"major":12,"minor":4,"patch":0}
|-
| style="background:#eee;" | 28 October 2021
| style="background:#eee;" | 19.3
| style="background:#eee;" | Matrix
| style="background:#eee;" | {"major":12,"minor":4,"patch":0}
|-
| style="background:#eee;" | 04 March 2022
| style="background:#eee;" | 19.4
| style="background:#eee;" | Matrix
| style="background:#eee;" | {"major":12,"minor":4,"patch":0}
|-
| TBA 2022
| 20.0
| Nexus
| {"major":12,"minor":10,"patch":2}
|-
|}


=== PicturePlayer.Rotate ===
== Documentation ==
Rotate the current picture (clockwise or anticlockwise?)
Kodi's JSON-RPC API has been designed to be self-documented i.e. a call to JSONRPC.Introspect results in a JSON-RPC response containing a documentation for all the available methods and data types. While this documentation is very incomplete and partly wrong for version 2 it is provided as a full [http://tools.ietf.org/html/draft-zyp-json-schema-03 JSON schema] starting with version 3. As the documentation retrieved in that way is always specific to the used version of Kodi, it is (especially for development versions) the best documentation available and should be preferred over the wiki documentation as the latter always documents the API of the latest development.


== AudioPlaylist ==
== Debugging ==
=== AudioPlaylist.Play ===
=== Output format ===
Starts playing a playlist
To be able to support easier debugging of (third-party) development using the JSON-RPC API, the JSON output generated by Kodi can be pretty-printed by setting
<pre>
<syntaxhighlight lang="xml" enclose="div">
PARAMETER          number     id number of a song to play
<jsonrpc>
OR
     <compactoutput>false</compactoutput>
PARAMETER
</jsonrpc>
songid            number    id number of a song to play
</syntaxhighlight>
in the [[Advancedsettings.xml#.3Cjsonrpc.3E|advancedsettings.xml]]. Default JSON output will be in compact format to minimize sent data (especially useful for mobile devices).


RESULT
=== Direct interaction ===
status            boolean    whether method succeeded
To be able to test some methods of Kodi's JSON-RPC API, it can be of great help to be able to send a single hand-written JSON-RPC request to Kodi to see its effect and the generated response. Depending on the transport protocol used there are different possibilities to do that:
</pre>


=== AudioPlaylist.SkipPrevious ===
==== TCP ====
Skips to the previous track in the playlist
With a [http://en.wikipedia.org/wiki/Telnet telnet] connection (using [http://en.wikipedia.org/wiki/PuTTY PuTTY] on Windows or telnet on Linux) to port 9090 of the machine running Kodi it is possible to send and receive raw json data to/from Kodi. {{see also|SSH}}


=== AudioPlaylist.SkipNext ===
==== HTTP ====
Skips to the next track in the playlist
A simple way of manually sending HTTP requests containing a JSON-RPC request to Kodi is using the [http://chrome.google.com/extensions/detail/fhjcajmcbmldlhcimfajhfbgofnpcjmb Simple REST Client] extension for Google's Chrome/Chromium browser. It allows defining a URL and the HTTP request type ('''POST''' is what we need). The actual JSON-RPC request can be defined in the '''Data''' field and then sent to Kodi.


=== AudioPlaylist.GetItems ===
Returns a list of items in the playlist, if you chose the right playlist type, also returns state information
<pre>
RESULT
items              array      a list of items in the playlist
current            number?    (id? of) current song
playing            boolean    whether currently playing
paused            boolean    whether currently paused
</pre>


=== AudioPlaylist.Add ===
== External links ==
Adds a track to the current audio playlist
* [http://jsonrpc.org/spec.html JSON-RPC 2.0 specification]
<pre>
* [http://tools.ietf.org/html/draft-zyp-json-schema-03 A JSON Media Type for Describing the Structure and Meaning of JSON Documents (Draft 03)]
PARAMETER        unknown
</pre>


=== AudioPlaylist.Clear ===
Clears the current audio playlist
<pre>
PARAMETER        unknown
</pre>


=== AudioPlaylist.Shuffle ===
Shuffles the current audio playlist


=== AudioPlaylist.UnShuffle ===
[[Category:JSON-RPC]]
Removes the shuffle from the current audio playlist
 
== VideoPlaylist ==
Contains exact the same methods as AudioPlaylist, except it affects the current video playlist, see AudioPlaylist method calls
 
== Playlist ==
=== Playlist.Create ===
Creates a virtual playlist, optionally from another file or virtual playlist
 
<pre>
PARAMETER
playlist-virtual  string    OPTIONAL: id of an existing virtual playlist to copy from
playlist-file      string    OPTIONAL: id of an existing file playlist to copy from
 
RESULT
playlist-virtual  string    id of the new playlist
</pre>
 
=== Playlist.Destroy ===
Destroys (deletes) a virtual playlist
<pre>
PARAMETER
playlist-virtual  string    id of virtual playlist to delete
</pre>
 
=== Playlist.GetItems ===
Returns a list of items in the playlist, if you chose the right playlist type, also returns state information
<pre>
RESULT
items              array      a list of items in the playlist
name              string    name of the playlist
</pre>
 
=== Playlist.Add ===
Adds file(s) to a given playlist (file or virtual)
<pre>
PARAMETER
playlist-file      string    OPTIONAL: id of file playlist
playlist-virtual  string    OPTIONAL: id of virtual playlist
</pre>
 
=== Playlist.Remove ===
Removes file from a given playlist (file or virtual)
<pre>
PARAMETER
playlist-file      string        OPTIONAL: id of file playlist
playlist-virtual  string        OPTIONAL: id of virtual playlist
item              string/number id of item to remove
</pre>
 
=== Playlist.Clear ===
Clears a given playlist
<pre>
PARAMETER
playlist-file      string    OPTIONAL: id of file playlist
playlist-virtual  string    OPTIONAL: id of virtual playlist
</pre>
 
=== Playlist.Swap ===
Swaps the position of two items in a given playlist
<pre>
PARAMETER
playlist-file      string    OPTIONAL: id of file playlist
playlist-virtual  string    OPTIONAL: id of virtual playlist
item1              number    id of first item
item2              number    id of second item
</pre>
 
 
=== Playlist.Shuffle ===
Shuffles the playlist
<pre>
PARAMETER
playlist-file      string    OPTIONAL: id of file playlist
playlist-virtual  string    OPTIONAL: id of virtual playlist
</pre>
 
=== Playlist.UnShuffle ===
Removes the shuffle from the playlist
<pre>
PARAMETER
playlist-file      string    OPTIONAL: id of file playlist
playlist-virtual  string    OPTIONAL: id of virtual playlist
</pre>
 
== Files ==
Many functions in this namespace allow filtering by type, valid types are the following:
<pre>
video
music
pictures
files
programs
</pre>
=== Files.GetSources ===
Returns a list of available source directories (directories in root folder)
<pre>
PARAMETER
media              string    media type filter, see Files namespace documentation for details
 
RESULT
shares            array      a list of file items in the directory
</pre>
 
=== Files.Download ===
Returns information about how to download a file (does not return the file itself)
 
=== Files.GetDirectory ===
Returns a list of items in a directory, items can be filtered by type.
<pre>
PARAMETER
directory          string    the directory to list, e.g. foo/bar
media              string    media type filter, see Files namespace documentation for details
recursive          boolean    TRUE if data about subdirectories should be included
 
RESULT
directories        array      sub-directories in this directory
files              array      files in this directory
</pre>
 
== AudioLibrary ==
=== AudioLibrary.GetArtists ===
Returns a list of artists in the audio library
<pre>
PARAMETER
genreid            number    filters by this genre id
 
RESULT
artists            array      artists in the library
</pre>
 
=== AudioLibrary.GetAlbums ===
Returns a list of albums in the audio library
<pre>
PARAMETER
genreid            number    filters by this genre id
artistid          number    filters by this artist id
start              number    integer value to start result listing from
end                number    integer value to end result listing from
 
RESULT
albums            array      artists in the library
</pre>
 
=== AudioLibrary.GetSongs ===
Returns a list of albums in the audio library
<pre>
PARAMETER
genreid            number    filters by this genre id
artistid          number    filters by this artist id
albumid            number    filters by this album id
 
RESULT
albums            array      artists in the library
</pre>
 
=== AudioLibrary.ScanForContent ===
Scans file system for new audio content
 
 
== VideoLibary ==
=== VideoLibrary.GetMovies ===
Returns a list of movies in the video library
<pre>
PARAMETER
fields            string    OPTIONAL: fields to return information for
sortmethod        string    OPTIONAL: method to sort the returned list
sortorder        string    OPTIONAL: order of sorting, "ascending" or "descending"
start            number    OPTIONAL: index to start listing from
end              number    OPTIONAL: index to end listing at
 
RESULT
movies            array      movies in the library
</pre>
 
=== VideoLibrary.GetTVShows ===
Returns a list of tv shows in the video library
<pre>
PARAMETER
fields            string    OPTIONAL: fields to return information for
sortmethod        string    OPTIONAL: method to sort the returned list
sortorder        string    OPTIONAL: order of sorting, "ascending" or "descending"
start            number    OPTIONAL: index to start listing from
end              number    OPTIONAL: index to end listing at
 
RESULT
tvshows          array      movies in the library
</pre>
 
=== VideoLibrary.GetSeasons ===
Returns a list of seasons for a given tv show
<pre>
PARAMETER
tvshowid          number    id of the tv show to get seasons for
 
RESULT
seasons          array      seasons for the tv show
</pre>
 
=== VideoLibrary.GetEpisodes ===
Returns a list of episodes for a tv show and season
<pre>
PARAMETER
tvshowid          number    id of the tv show
season            number    id of the season to get episodes for
 
RESULT
episodes          array      seasons for the tv show
</pre>
 
=== VideoLibrary.GetMusicVideos ===
Returns a list of Music videos in the video library
<pre>
PARAMETER
artistid          number    id of the artist
albumid          number    id of the album
fields            string    OPTIONAL: fields to return information for
sortmethod        string    OPTIONAL: method to sort the returned list
sortorder        string    OPTIONAL: order of sorting, "ascending" or "descending"
start            number    OPTIONAL: index to start listing from
end              number    OPTIONAL: index to end listing at
 
RESULT
musicvideos      array      music videos in the library
</pre>
 
=== VideoLibrary.GetRecentlyAddedMovies ===
eturns a list of recently added movies in the video library
<pre>
PARAMETER
fields            string    OPTIONAL: fields to return information for
sortmethod        string    OPTIONAL: method to sort the returned list
sortorder        string    OPTIONAL: order of sorting, "ascending" or "descending"
start            number    OPTIONAL: index to start listing from
end              number    OPTIONAL: index to end listing at
 
RESULT
movies            array      movies in the library
</pre>
 
=== VideoLibrary.GetRecentlyAddedEpisodes ===
Returns a list of recently added episodes to the library
<pre>
PARAMETER
 
RESULT
episodes          array      seasons for the tv show
</pre>
 
=== VideoLibrary.GetRecentlyAddedMusicVideos ===
Returns a list of Music videos in the video library
<pre>
PARAMETER
fields            string    OPTIONAL: fields to return information for
sortmethod        string    OPTIONAL: method to sort the returned list
sortorder        string    OPTIONAL: order of sorting, "ascending" or "descending"
start            number    OPTIONAL: index to start listing from
end              number    OPTIONAL: index to end listing at
</pre>
 
=== VideoLibrary.ScanForContent ===
Scans file system for new video content
 
== System ==
=== System.Shutdown ===
Shuts down the system
 
=== System.Suspend ===
Suspends the system
 
=== System.Hibernate ===
Hibernates the system
 
=== System.Reboot ===
Reboots the system
 
=== System.GetInfoLabels ===
Get info labels about the system
 
<pre>
PARAMETER        array      of string    <field name>s to return information for
 
RESULT            array      of object
<field name>    string    label that field 
</pre>
 
=== System.GetInfoBooleans ===
Get info booleans about the system
Available field names: <code>system.canshutdown  system.canpowerdown  system.cansuspend  system.canhibernate  system.canreboot</code>
<pre>
PARAMETER        array      of string    <field name>s to return information for
 
RESULT            array      of object
<field name>    boolean    value of that field 
</pre>
Example parameters:<br />
<code>[ 'system.canshutdown', 'system.cansuspend' ]</code>
 
Example result: <br />
<code>[ { 'system.canshutdown' : true }, { 'system.cansuspend' : true }]</code>
 
== XBMC ==
=== XBMC.GetVolume ===
Gets the current volume
<pre>
RESULT            number    volume 
</pre>
 
=== XBMC.SetVolume ===
Sets the current volume
<pre>
PARAMETER        number    volume to set to
</pre>
 
=== XBMC.ToggleMute ===
Toggle volume mute on/off, returns same as XBMC.GetVolume
 
=== XBMC.Play ===
Starts playback
 
=== XBMC.StartSlideshow ===
Starts slideshow
<pre>
PARAMETER        string    command to start slideshow with
OR
PARAMETER
directory        string    directory to show pictures from
random          boolean    True if show in random order
recursive        boolean    True if include pictures from subdirectories
</pre>
=== XBMC.Log ===
Logs a line in xbmc.log
<pre>
PARAMETER        string    text to log
OR
PARAMETER
message          string    text to log
level            string    log level, "debug", "info", "notice", "warning", "error", "severe", "fatal", "none"
</pre>
 
=== XBMC.Quit ===
Exits XBMC
 
 
== Development ==
There are about 3 different state returns, that are subtly different, if we want to return player state just reuse State method?
 
Why are there 2 VideoPlayer and AudioPlayer namespaces when they are an arbitrary distinction? Both are handled by the same functions and require extra processing to check the caller used the right namespace.
 
Same for VideoPlaylist and AudioPlaylist, both map directly to AVPlaylist. The third Playlist namespace contains create and destroy commands, implying there is no difference between Audio and Video playlists
 
Use objects for all parameter values, as per JSON 2.0 spec.
Current functions not using an object for parameters
<pre>
AVPlayerOperations.cpp
CAVPlayerOperations::SeekTime
CAVPlayerOperations::SeekPercentage
 
PicturePlayerOperations.cpp
CPicturePlayerOperations::Zoom
 
AVPlaylistOperations.cpp
CAVPlaylistOperations::Play
 
PlaylistOperations.cpp
CPlaylistOperations::Destroy
CPlaylistOperations::Remove      Remote ambiguity about parameter type
 
AudioLibrary.cpp
CAudioLibrary::GetAlbum        albumid should be genreid
 
XBMCOperations.cpp
CXBMCOperations::StartSlideshow
CXBMCOperations::Log
</pre>

Latest revision as of 05:47, 20 May 2022

JSON-RPC Pages
Main JSON-RPC Page
- v8 (Krypton)
- v10 (Leia)
- v12 (Matrix)
- v13 (Nexus)
- v14 (Omega)
Examples
All JSON-RPC Pages
Home icon grey.png   ▶ Development ▶ JSON-RPC API


JSON-RPC is a HTTP- and/or raw TCP socket-based interface for communicating with Kodi. It replaces the deprecated HTTP API, and offers a more secure and robust mechanism in the same format. It is based upon the JSON-RPC 2.0 specification.

Each method in the interface can have different security needs which means one client may be allowed to only control playback while another can only read and manipulate the library. In version 2 (first stable) and 4 all clients are granted full authority but will later be forced to ask for privileges and the user of Kodi will have to grant said client access. The design of JSON-RPC is that most methods should behave roughly the same and maintain consistency while hiding the mechanics of Kodi from the client creator.

In Kodi JSON-RPC can be accessed over a variety of transports and has been designed from the ground up to be flexible to allow control over new transports easily. Some of the transports have different limitations which will be enforced upon the interaction over that transport. As an example HTTP transports allow response and downloading of files while the raw TCP transport allows response and notifications (events and information Kodi sends to its clients). Depending on the client's needs it will choose one (or many) of the available transports.


Enabling JSON-RPC

Since the interface is available on many transports enabling it depends on the transport.

  • Python: Always enabled
  • HTTP: In System/Settings/Network/Services activate Allow control of Kodi via HTTP (see Enabling the webserver)
  • TCP: In System/Settings/Network/Services activate Allow programs on this system to control Kodi for localhost access only and Allow programs on other systems to control Kodi for access from other computers as well

Note: The EventServer is a different interface for sending remote keypresses to Kodi, and must be enabled separately, some programs may use both interfaces.

Transports & Functionalities

Transports

Python

The Python transport can only be used by Kodi addons through the executeJSONRPC method provided by the xbmc python library. As it must be available to every addon in an Kodi installation it must not be enabled or disabled by the user.

HTTP

The HTTP transport can be used by third-party applications running on the same machine as Kodi or on a different machine which can access the machine running Kodi using the HTTP protocol. Because this transport allows applications outside Kodi to control Kodi, it has to be manually enabled (see Enabling JSON-RPC) by the user.

POST

Third-party applications can access Kodi's JSON-RPC API by sending JSON-RPC requests embedded in HTTP POST requests to the following URL

http://<your-ip>:<your-port>/jsonrpc

Starting with Frodo nightly builds it is mandatory to set the HTTP header field Content-Type: application/json

GET

Third-party application can access Kodi's JSON-RPC API by sending JSON-RPC requests embedded in a HTTP GET parameter called request. The JSON-RPC request must be URL encoded and sent to the following URL

http://<your-ip>:<your-port>/jsonrpc?request=<url-encoded-request>

TCP

The TCP transport can be used by third-party applications running on the same machine as Kodi or on a different machine which can access the machine running Kodi using the TCP protocol. Because this transport allows applications outside Kodi to control Kodi it has to be manually enabled (see Enabling JSON-RPC) by the user. Once enabled, third-party applications can access Kodi's JSON-RPC API by opening a TCP socket on port 9090 (this port can be configured in the advanced settings file) and sending raw JSON-RPC requests over that socket. Please note that no delimiters are provided in between notifications and/or responses. As such, your client needs to be able to deal with this, eg. by counting and matching curly braces ({}).

WebSocket

The WebSocket transport has been added since Version 5 and can be used by third-party applications running on the same machine as Kodi or on a different machine which can access the machine running Kodi using the Websocket protocol. The supported versions are 8 (draft hybi-10) and 13 (RFC 6455). Because this transport allows applications outside Kodi to control Kodi it has to be manually enabled (see Enabling JSON-RPC) by the user. Once enabled, third-party applications can access Kodi's JSON-RPC API by sending a WebSocket protocol handshake to the following URI

ws://<your-ip>:<configured tcp port>/jsonrpc

It is important to send the handshake on the port of Kodi's TCP server (by default 9090, but this port can be configured in the advanced settings file). After having successfully finished the handshake third-party applications can send WebSocket protocl messages over that connection.

Functionalities

Response

The Response functionality is the only functionality that should be present in every transport available as it describes the functionality to respond to a JSON-RPC request with a valid JSON-RPC response (be it an error message or an actual response).

Notifications

The Notifications functionality includes both server-side (from the server to clients) and client-side (from clients to the server) notifications. A JSON-RPC notification is a valid JSON-RPC request with no id property. Following the JSON-RPC 2.0 specification any JSON-RPC request with no id must be considered as a notification and the receiver must not send a response upon a notification.

In the specific case of Kodi, server-side notifications are used to inform clients about certain events to relieve clients of the need to periodically poll for certain events. Furthermore there are two ways of client-side notifications. Using JSONRPC.NotifyAll it is possible to ask Kodi to relay the message in the JSON-RPC request to all other connected clients. The second way is to send JSON-RPC requests without an id property in case the client does not care about the response (e.g. the method Player.Stop does not return any useful information to the client).

Direct file download

The Direct file download functionality is the ability to directly download files from Kodi by calling Files.Download. In this case the term direct means that the download happens within the JSON-RPC response of the Files.Download request.

Redirected file download

The Redirected file download functionality is the ability to indirectly download files from Kodi by calling Files.PrepareDownload and using the data received in the response to download the file over a different protocol (like HTTP, FTP ...) or another socket. As the Redirected file download is very transport specific, it must be handled separately for every transport supporting it.

Comparison

The following table shows all the available transports and what functionalities they support

Transport Response Notifications Direct file
download
Redirected file
download
Python Yes No No No
TCP Yes Yes No No
HTTP POST Yes No No Yes
GET1 Yes No No Yes
WebSocket1 Yes Yes No No

1 Added in Version 5

API versions

The JSON-RPC API exposed by Kodi is constantly extended to provide better and more functionality to third party applications. For that reason Kodi provides a version information through the JSONRPC.Version method. The rule is that odd version numbers describe an API state, that is not stable and under heavy development whereas even version numbers describe a stable API. Therefore the version number can be used by third-party clients to check if their application might not be fully compatible with the JSON-RPC API exposed by a user's Kodi installation.

Starting with XBMC v12 (Frodo) we started using a new versioning system (<major>.<minor>.<patch>) for the JSON-RPC API. Frodo stable is version 6.0.0 and from now on with every bugfix the <patch> part of the version is increased, with every feature addition to the API, the <minor> version is increased (and the <patch> version reset to 0) and with every backwards incompatible change, the <major> version is increased.

Release JSON-RPC 2.0 specification Transports
API Version Version Name Method calls Notifications
(server-side)
Notifications
(client-side)
Parameters
by-name
Parameters
by-position
Batch requests Python TCP HTTP POST HTTP GET WebSocket
Version 2 10.0 Dharma Yes Yes No Yes No No Yes Yes Yes No No
Version 3 / 4 pre-11 / 11.0 Eden Yes Yes Yes Yes Yes Yes Yes Yes Yes No No
Version 5 / 6 pre-12 / 12.0 Frodo Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 6 13.0 Gotham Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 6 13.1 Gotham Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 6 13.2 Gotham Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 6 14.0 Helix Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 6 14.1 Helix Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 6 14.2 Helix Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 6 15.0 Isengard Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 6 15.1 Isengard Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 6 15.2 Isengard Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 6 16.0 Jarvis Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 6 16.1 Jarvis Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 8 17.0 Krypton Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
Version 10 18 Leia Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes1 Yes
Version 12 19 Matrix Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes1 Yes

1For information requests only, actions require POST

Release JSONRPC.Version
Date Version Codename ["version"]
18 December 2010 10.0 Dharma 2
10 March 2011 10.1 Dharma 2
24 March 2012 11.0 Eden 4
29 January 2013 12.0 Frodo {"major":6,"minor":0,"patch":0}
18 March 2013 12.1 Frodo {"major":6,"minor":0,"patch":3}
03 May 2013 12.2 Frodo {"major":6,"minor":0,"patch":3}
24 December 2013 12.3 Frodo {"major":6,"minor":0,"patch":3}
04 May 2014 13.0 Gotham {"major":6,"minor":14,"patch":3}
05 June 2014 13.1 Gotham {"major":6,"minor":14,"patch":3}
17 August 2014 13.2 Gotham {"major":6,"minor":14,"patch":3}
23 December 2014 14.0 Helix {"major":6,"minor":21,"patch":2}
30 January 2014 14.1 Helix {"major":6,"minor":21,"patch":2}
26 March 2014 14.2 Helix {"major":6,"minor":21,"patch":2}
21 July 2015 15.0 Isengard {"major":6,"minor":25,"patch":2}
16 August 2015 15.1 Isengard {"major":6,"minor":25,"patch":2}
19 October 2015 15.2 Isengard {"major":6,"minor":25,"patch":2}
21 February 2016 16.0 Jarvis {"major":6,"minor":32,"patch":4}
24 April 2016 16.1 Jarvis {"major":6,"minor":32,"patch":5}
05 February 2017 17.0 Krypton {"major":8,"minor":0,"patch":0}
20 March 2017 17.1 Krypton {"major":8,"minor":0,"patch":0}
23 May 2017 17.2 Krypton {"major":8,"minor":0,"patch":0}
24 May 2017 17.3 Krypton {"major":8,"minor":0,"patch":0}
22 August 2017 17.4 Krypton {"major":8,"minor":0,"patch":0}
23 October 2017 17.5 Krypton {"major":8,"minor":0,"patch":0}
14 November 2017 17.6 Krypton {"major":8,"minor":0,"patch":0}
29 January 2019 18.0 Leia {"major":10,"minor":1,"patch":1}
17 February 2019 18.1 Leia {"major":10,"minor":1,"patch":2}
22 April 2019 18.2 Leia {"major":10,"minor":3,"patch":0}
27 June 2019 18.3 Leia {"major":10,"minor":3,"patch":0}
01 September 2019 18.4 Leia {"major":10,"minor":3,"patch":0}
17 November 2019 18.5 Leia {"major":10,"minor":3,"patch":0}
02 March 2020 18.6 Leia {"major":10,"minor":3,"patch":0}
21 May 2020 18.7 Leia {"major":10,"minor":3,"patch":0}
01 June 2020 18.7.1 Leia {"major":10,"minor":3,"patch":0}
14 June 2020 18.7.2 Leia {"major":10,"minor":3,"patch":0}
29 July 2020 18.8 Leia {"major":10,"minor":3,"patch":0}
24 October 2020 18.9 Leia {"major":10,"minor":3,"patch":0}
20 February 2021 19.0 Matrix {"major":12,"minor":2,"patch":1}
10 May 2021 19.1 Matrix {"major":12,"minor":3,"patch":0}
09 October 2021 19.2 Matrix {"major":12,"minor":4,"patch":0}
28 October 2021 19.3 Matrix {"major":12,"minor":4,"patch":0}
04 March 2022 19.4 Matrix {"major":12,"minor":4,"patch":0}
TBA 2022 20.0 Nexus {"major":12,"minor":10,"patch":2}

Documentation

Kodi's JSON-RPC API has been designed to be self-documented i.e. a call to JSONRPC.Introspect results in a JSON-RPC response containing a documentation for all the available methods and data types. While this documentation is very incomplete and partly wrong for version 2 it is provided as a full JSON schema starting with version 3. As the documentation retrieved in that way is always specific to the used version of Kodi, it is (especially for development versions) the best documentation available and should be preferred over the wiki documentation as the latter always documents the API of the latest development.

Debugging

Output format

To be able to support easier debugging of (third-party) development using the JSON-RPC API, the JSON output generated by Kodi can be pretty-printed by setting

<jsonrpc>
    <compactoutput>false</compactoutput>
</jsonrpc>

in the advancedsettings.xml. Default JSON output will be in compact format to minimize sent data (especially useful for mobile devices).

Direct interaction

To be able to test some methods of Kodi's JSON-RPC API, it can be of great help to be able to send a single hand-written JSON-RPC request to Kodi to see its effect and the generated response. Depending on the transport protocol used there are different possibilities to do that:

TCP

With a telnet connection (using PuTTY on Windows or telnet on Linux) to port 9090 of the machine running Kodi it is possible to send and receive raw json data to/from Kodi.

HTTP

A simple way of manually sending HTTP requests containing a JSON-RPC request to Kodi is using the Simple REST Client extension for Google's Chrome/Chromium browser. It allows defining a URL and the HTTP request type (POST is what we need). The actual JSON-RPC request can be defined in the Data field and then sent to Kodi.


External links