External control and automation interfaces
Kodi provides external clients, add-ons, web interfaces, and scripts with several ways to control playback, manage media, change settings, and receive state changes. These paths use different transports and languages but converge on Kodi's application services. For request formats and transport rules, see API invocation. For add-on lifecycle and script use, see Scripting integration. For network-facing service setup, see Network services. For settings and profile behavior, see Settings and profiles.
Interface model
External control is an adapter layer around Kodi's application services. A client selects a path by the kind of control it needs: typed remote data, simple input, in-process script access, a custom web surface, or older add-on compatibility.
This diagram shows how external requests reach Kodi services and how service events return through announcements.
flowchart LR
Remote[Remote client] --> RPC[JSON-RPC]
Remote --> Event[EventServer input]
Addon[Python add-on] --> Bindings[Python and SWIG bindings]
Web[Python web interface] --> WSGI[WSGI layer]
Legacy[Legacy Python API] --> Bindings
RPC --> Services[Kodi services]
Event --> Builtins[Built-in commands]
Bindings --> Services
WSGI --> Bindings
Builtins --> Services
Services --> Announce[Announcement manager]
Announce --> RPC
Announce --> Bindings
Interface choices
The interface choice sets the request style and the feedback a client can receive. JSON-RPC is the main typed remote API. Built-ins and EventServer focus on commands and input. Python bindings provide direct script access, while WSGI lets an add-on define its own HTTP surface.
| Need | Main path | Result |
|---|---|---|
| Read or change Kodi data over a network | JSON-RPC | Structured results and, on supported transports, event notifications |
| Send remote-control input | EventServer or built-ins | Input actions or named commands |
| Run Kodi-aware add-on code | Python and SWIG bindings | In-process Kodi API access |
| Serve a custom web page or control API | Python WSGI | Add-on-defined HTTP requests and responses |
| Keep older add-ons working | Legacy APIs | Familiar player, monitor, GUI, and data objects |
References: xbmc/…/PlayerOperations.cpp• L350-417 xbmc/…/PlayerBuiltins.cpp• L922-938 xbmc/…/XBPython.cpp• L37-104
Announcement delivery
Announcement manager
An announcement is Kodi's event message for a state change that other components or clients may need to know about. The manager queues these messages, adds shared item data when available, and dispatches them to listeners that match the event category.
The sender value and the category-plus-message name form a public event contract. Python monitors and JSON-RPC clients use these values to identify events, so the standard sender remains xbmc. Categories cover areas such as playback, the GUI, media libraries, the system, input, PVR, and sources.
References: xbmc/…/AnnouncementManager.h• L36-64 xbmc/…/AnnouncementManager.cpp• L225-274 xbmc/…/AnnouncementManager.cpp• L276-395
Remote announcements
Stream JSON-RPC clients can receive announcements as JSON-RPC 2.0 notifications. Each client has its own category filter, so one client can reduce its event stream without changing the events seen by other clients. The HTTP /jsonrpc path handles request and response traffic but does not provide this broadcast channel.
Python receives the same announcements through the Python runtime. The runtime turns them into monitor callbacks and maps selected library and GUI events to older monitor methods.
References: xbmc/…/IJSONRPCAnnouncer.h• L17-44 xbmc/…/TCPServer.cpp• L241-271 xbmc/…/HTTPJsonRpcHandler.cpp• L166-182 xbmc/…/XBPython.cpp• L132-179
Built-in commands
Built-in commands
Built-in commands are Kodi's compact command language for common actions. A command has a name and optional parameters. Kodi routes the name to the matching application service.
Player commands control playback, playlists, seeking, speed, subtitles, discs, and related state. Library commands update, clean, export, search, and refresh media data. The library path supports both the original export form and an extended form with explicit destination and content options. Python can call these commands directly, and remote input paths can reach them.
Command results depend on Kodi's current state. For example, a player command needs a matching active player, and a library task may be rejected while another scan or clean is active. User-facing forms can show dialogs, while automation forms can suppress them.
References: xbmc/…/PlayerBuiltins.cpp• L127-417 xbmc/…/PlayerBuiltins.cpp• L696-733 xbmc/…/PlayerBuiltins.cpp• L922-948 xbmc/…/LibraryBuiltins.cpp• L55-116 xbmc/…/LibraryBuiltins.cpp• L118-310 xbmc/…/LibraryBuiltins.cpp• L314-397 xbmc/…/LibraryBuiltins.cpp• L472-483
JSON-RPC service
JSON-RPC invocation
JSON-RPC is Kodi's structured interface for remote reads and state changes. A request names a method and supplies typed parameters. Kodi validates the request, checks access rules, and returns a result or a standard error. Notifications omit a request ID and do not need a response. Batch requests are also supported.
The service description publishes methods, types, parameters, return values, permissions, and notifications. Clients can use introspection to discover this contract. The service covers application state, playback, playlists, files, media libraries, add-ons, GUI control, PVR, profiles, settings, and system actions.
Methods remain state-aware. A client often discovers the active player or a library item before it requests a change. The returned status is part of the contract because a valid method can still be unsuitable for the current player, profile, library task, or path.
JSON-RPC methods can reuse built-in commands when both paths represent the same product action. Library scans, cleans, and exports therefore follow the same command path as local automation.
For request construction, discovery, validation, and transport behavior, see API invocation.
References: xbmc/…/JSONRPC.cpp• L127-339 xbmc/…/JSONServiceDescription.cpp• L46-270 xbmc/…/PlayerOperations.cpp• L124-216 xbmc/…/VideoLibrary.cpp• L901-1137
Library and file operations
The library and file parts of JSON-RPC expose a common view of Kodi items. Clients can list and filter music, video, and file data, request selected properties, sort and limit results, read artwork, and update supported metadata. Shared item handling keeps identifiers, media types, paths, artwork, and extra fields consistent across these operations.
Audio operations update music metadata and artwork. Video operations read and update movies, shows, seasons, episodes, and music videos. They also support refresh, removal, source content, scan, export, and clean actions. Show-level playback changes can propagate to episode state so the library remains coherent.
File operations expose sources, directories, file details, metadata updates, and downloads. Remote access checks protect paths, while the selected transport decides whether a download is direct or redirected. Favourites provide a related control surface for saved windows, media paths, scripts, and Android applications.
References: xbmc/…/AudioLibrary.cpp• L42-97 xbmc/…/AudioLibrary.cpp• L753-841 xbmc/…/VideoLibrary.cpp• L36-149 xbmc/…/VideoLibrary.cpp• L615-690 xbmc/…/VideoLibrary.cpp• L901-1137 xbmc/…/FileOperations.cpp• L44-179 xbmc/…/FileOperations.cpp• L182-299 xbmc/…/FavouritesOperations.cpp• L25-161 xbmc/…/FileItemHandler.cpp• L292-515
Settings and profiles
JSON-RPC exposes settings and profiles as controlled application state. Clients can discover visible settings through their section and category tree, read typed values, change supported values, reset them, and inspect skin settings. The setting description includes level, type, control, current value, defaults, and valid choices.
Profile methods list profiles, report the current profile, and request a profile change. A locked profile requires the allowed prompt or password path before Kodi accepts the change. This makes profile access part of the control contract rather than a simple name lookup.
References: xbmc/…/SettingsOperations.cpp• L33-333 xbmc/…/SettingsOperations.cpp• L383-449 xbmc/…/SettingsOperations.h• L36-61 xbmc/…/ProfilesOperations.cpp• L25-137
JSON-RPC transports
The JSON-RPC service separates request handling from network transport. A transport declares whether it supports responses, announcements, and file transfer. HTTP serves /jsonrpc through GET or POST, while the stream service supports TCP and WebSocket clients and can send announcements back to them.
Transport permissions affect what a client can do. HTTP GET is limited to read access, HTTP does not broadcast announcements, and file operations depend on transport support for direct transfer or redirection.
References: xbmc/…/ITransportLayer.h• L17-34 xbmc/…/JSONUtils.h• L209-225 xbmc/…/HTTPJsonRpcHandler.cpp• L23-110 xbmc/…/TCPServer.h• L28-42 xbmc/…/TCPServer.h• L89-103
Scripting integration
Python runtime
Kodi embeds Python for add-on scripts and Python-backed web interfaces. The runtime owns script execution, playback callbacks, monitor callbacks, and the delivery of Kodi announcements to Python code.
Python scripts use the xbmc family of modules to call Kodi services, run built-ins, invoke JSON-RPC in process, receive playback events, and wait for Kodi events. Python web interfaces use the same runtime and bindings while adding request and response handling.
For script lifecycle rules and integration patterns, see Scripting integration.
References: xbmc/…/XBPython.cpp• L37-104 xbmc/…/XBPython.cpp• L132-179 xbmc/…/XBPython.cpp• L325-500
Generic script invocation
The generic script layer gives Kodi one language-neutral control point for supported script runtimes. A language handler declares the file types it supports and creates an invoker for each script.
The invocation layer can start scripts in the background or wait for completion. It tracks running scripts, stops one script or all scripts, and removes finished invokers. This keeps script lifecycle control separate from any one language binding.
References: xbmc/…/ILanguageInvocationHandler.h• L15-33 xbmc/…/ILanguageInvoker.h• L20-67 xbmc/…/ScriptInvocationManager.cpp• L101-199 xbmc/…/ScriptRunner.cpp• L109-164
Python and SWIG bindings
SWIG generates the Python-facing modules from C++ interface descriptions. The bindings expose Kodi's media, GUI, file, add-on, and web objects while keeping the object and callback model expected by add-ons.
The binding boundary also defines shared rules for ownership, collection conversion, callbacks, exceptions, and cross-module type identity. Common binding setup keeps internal SWIG types out of add-on modules and gives shared Kodi types consistent Python behavior. Older string inputs remain supported during migration, but text must use valid UTF-8.
References: xbmc/…/README.md• L1-48 xbmc/…/kodi_common.i• L9-98 xbmc/…/kodi_list.i• L9-53 xbmc/…/kodi_addonclass.i• L9-145 xbmc/…/kodi_string.i• L13-119 xbmc/…/SwigRuntime.cpp• L9-23
Compatibility paths
EventServer input
EventServer is a legacy UDP path for remote-control devices. It accepts event packets and turns them into queued input actions or named built-in commands. It is narrower than JSON-RPC because it focuses on control input rather than typed data access and results.
References: xbmc/…/EventServer.h• L28-66 xbmc/…/EventServer.cpp• L120-197 xbmc/…/EventServer.cpp• L274-324
Legacy Python API
The legacy Python API keeps long-standing add-on entry points connected to current Kodi services. The xbmc module provides system and playback calls, built-in execution, local JSON-RPC execution, and server control. Player provides playback control and callbacks. Monitor provides event callbacks and an abort wait for long-running scripts.
GUI and media objects extend this path with dialogs, windows, controls, list items, media tags, artwork, and stream details. Picture tags expose image resolution and capture time for add-ons. Game tags provide structured game metadata for list items, including identity, platform, credits, ratings, player count, age rating, trailer, and tags. The date value can use a W3C date-time form, while resolution must contain positive dimensions. Newer tag objects provide the preferred structured metadata path, while older ListItem setters and string-based fields remain as compatibility paths and may report deprecation warnings. xbmc.executeJSONRPC() uses the shared JSON-RPC dispatcher in process, so it is not a separate remote API.
References: xbmc/…/ModuleXbmc.h• L29-38 xbmc/…/ModuleXbmc.h• L130-206 xbmc/…/ModuleXbmc.cpp• L75-145 xbmc/…/InfoTagPicture.cpp• L28-101 xbmc/…/InfoTagGame.h• L25-35 xbmc/…/InfoTagGame.h• L234-338 xbmc/…/InfoTagGame.h• L476-580 xbmc/…/InfoTagGame.cpp• L43-195 xbmc/…/Dialog.cpp• L49-201 xbmc/…/InfoTagVideo.cpp• L118-239 xbmc/…/InfoTagVideo.cpp• L699-755 xbmc/…/ListItem.cpp• L156-201 xbmc/…/ListItem.cpp• L403-576 xbmc/…/aojsonrpc.h• L16-29
WSGI web interfaces
A WSGI web interface is a Python web application hosted by Kodi's web server. Kodi maps an HTTP request to an add-on entry point, provides request data through a WSGI input stream, and sends back the add-on's status, headers, and body.
This path differs from /jsonrpc because the add-on defines its own routes and response format. It can still use the Python bindings or call JSON-RPC from inside Kodi.
References: xbmc/…/HTTPPythonHandler.cpp• L102-224 xbmc/…/HTTPPythonWsgiInvoker.cpp• L121-384 xbmc/…/WsgiInputStream.h• L92-118 xbmc/…/WsgiResponse.h• L22-74
Change checklist
When these files or sections are changed, remember to consider these:
- Keep announcement sender values, category flags, message names, item payloads, listener removal, and shutdown order aligned across JSON-RPC and Python monitors.
- Keep JSON-RPC method descriptions aligned with typed parameters, visible setting levels, result fields, permissions, and transport capabilities.
- Keep common item conversion aligned with media IDs, media types, paths, artwork, requested properties, sorting, and limits.
- Keep audio and video update rules aligned with artwork removal, playback state, related items, library notifications, and refresh or scan queues.
- Keep file access checks aligned with directory listing, file details, metadata updates, and direct or redirected downloads.
- Keep profile lock checks aligned with profile loading and the settings and profiles contract.
- Keep built-in command names, parameter forms, library task state checks, and player behavior aligned with the Python and JSON-RPC paths that invoke them.
- Keep SWIG ownership, shared types, text conversion, module metadata, and generated Python module behavior aligned across all binding inputs.
- Keep game-tag fields, rating limits, list-item integration, and off-screen GUI access aligned with the legacy Python contract.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A client expects announcements from HTTP JSON-RPC | The client receives no broadcast events | Use a stream transport or poll with requests |
| A JSON-RPC call uses a transport without the needed permission or capability | Kodi rejects the call or cannot transfer the file | Check method permissions and transport capabilities |
| A player or library request does not match current Kodi state | Kodi returns an error or does not perform the action | Discover current state and use the returned status |
| A remote file path fails the access check | Kodi rejects the directory, detail, or update request | Use a path allowed for remote access |
| A locked profile lacks an accepted prompt or password | Kodi does not load the profile | Follow the profile lock contract |
| A script extension has no language handler | Kodi cannot start the script | Register the extension with the generic invocation layer |
| A Python callback runs during runtime teardown | The callback can target a destroyed add-on object | Stop scripts and remove callbacks before shutdown |
| An add-on sends invalid text or uses incompatible wrapped-object ownership | The binding call fails or the add-on uses an invalid object | Use UTF-8 text and the shared SWIG ownership rules |
| A picture tag receives a non-positive width or height | The legacy call raises a type error and does not set the resolution | Pass positive image dimensions |
| A game tag receives a rating outside the supported range | Kodi ignores the rating value | Pass a rating from 0.0 through 10.0 |
Key files
| File | Why to read it |
|---|---|
| xbmc/…/AnnouncementManager.h | Defines the shared event and listener contract. |
| xbmc/…/AnnouncementManager.cpp | Shows event queuing, item payloads, and listener dispatch. |
| xbmc/…/JSONRPC.cpp | Shows shared JSON-RPC request, response, notification, and error flow. |
| xbmc/…/AudioLibrary.cpp | Shows music library reads, metadata updates, artwork, and library actions. |
| xbmc/…/VideoLibrary.cpp | Shows video library reads, updates, playback state, and library actions. |
| xbmc/…/FileOperations.cpp | Shows remote file access, item details, and downloads. |
| xbmc/…/SettingsOperations.cpp | Shows settings discovery and typed setting control. |
| xbmc/…/ProfilesOperations.cpp | Shows profile discovery and lock-aware profile loading. |
| xbmc/…/ITransportLayer.h | Defines transport capabilities used by JSON-RPC operations. |
| xbmc/…/TCPServer.cpp | Shows stream request handling and remote announcement delivery. |
| xbmc/…/HTTPJsonRpcHandler.cpp | Shows the HTTP /jsonrpc entry point and its permissions. |
| xbmc/…/XBPython.cpp | Shows Python runtime setup, callbacks, announcements, and shutdown. |
| xbmc/…/ScriptInvocationManager.cpp | Shows language-neutral script tracking and control. |
| xbmc/…/README.md | Explains generated Python modules and binding constraints. |
xbmc/interfaces/swig/kodi_common.i | Defines the shared rules and types used by Kodi's generated Python modules. |
| xbmc/…/LibraryBuiltins.cpp | Shows library update, clean, export, search, and refresh commands. |
| xbmc/…/PlayerBuiltins.cpp | Shows playback, playlist, seek, subtitle, and disc commands. |
| xbmc/…/ModuleXbmc.h | Defines key compatibility-facing Python functions. |
| xbmc/…/ModuleXbmc.cpp | Shows built-in and local JSON-RPC calls from the legacy Python API. |
| xbmc/…/InfoTagPicture.cpp | Shows picture metadata access and validation for add-ons. |
| xbmc/…/InfoTagGame.h | Defines the structured game metadata contract exposed to Python add-ons. |
| xbmc/…/InfoTagGame.cpp | Shows game metadata access and updates through the legacy Python layer. |
| xbmc/…/InfoTagVideo.cpp | Shows structured media metadata and stream integration for add-ons. |
| xbmc/…/ListItem.cpp | Shows older list-item metadata paths and their migration to tag objects. |