Introducing a new way to review your PRs.

Read the announcement

xbmc / xbmc

Kodi is an award-winning free and open source home theater/media center software and entertainment hub for digital media. With its beautiful interface and powerful skinning engine, it's available for Android, BSD, Linux, macOS, iOS, tvOS and Windows.

View on GitHub

22 documents · Updated Oct 21, 2026

docs / external-interfaces

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.

NeedMain pathResult
Read or change Kodi data over a networkJSON-RPCStructured results and, on supported transports, event notifications
Send remote-control inputEventServer or built-insInput actions or named commands
Run Kodi-aware add-on codePython and SWIG bindingsIn-process Kodi API access
Serve a custom web page or control APIPython WSGIAdd-on-defined HTTP requests and responses
Keep older add-ons workingLegacy APIsFamiliar 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

TriggerConsequenceGuard
A client expects announcements from HTTP JSON-RPCThe client receives no broadcast eventsUse a stream transport or poll with requests
A JSON-RPC call uses a transport without the needed permission or capabilityKodi rejects the call or cannot transfer the fileCheck method permissions and transport capabilities
A player or library request does not match current Kodi stateKodi returns an error or does not perform the actionDiscover current state and use the returned status
A remote file path fails the access checkKodi rejects the directory, detail, or update requestUse a path allowed for remote access
A locked profile lacks an accepted prompt or passwordKodi does not load the profileFollow the profile lock contract
A script extension has no language handlerKodi cannot start the scriptRegister the extension with the generic invocation layer
A Python callback runs during runtime teardownThe callback can target a destroyed add-on objectStop scripts and remove callbacks before shutdown
An add-on sends invalid text or uses incompatible wrapped-object ownershipThe binding call fails or the add-on uses an invalid objectUse UTF-8 text and the shared SWIG ownership rules
A picture tag receives a non-positive width or heightThe legacy call raises a type error and does not set the resolutionPass positive image dimensions
A game tag receives a rating outside the supported rangeKodi ignores the rating valuePass a rating from 0.0 through 10.0

Key files

FileWhy to read it
xbmc/…/AnnouncementManager.hDefines the shared event and listener contract.
xbmc/…/AnnouncementManager.cppShows event queuing, item payloads, and listener dispatch.
xbmc/…/JSONRPC.cppShows shared JSON-RPC request, response, notification, and error flow.
xbmc/…/AudioLibrary.cppShows music library reads, metadata updates, artwork, and library actions.
xbmc/…/VideoLibrary.cppShows video library reads, updates, playback state, and library actions.
xbmc/…/FileOperations.cppShows remote file access, item details, and downloads.
xbmc/…/SettingsOperations.cppShows settings discovery and typed setting control.
xbmc/…/ProfilesOperations.cppShows profile discovery and lock-aware profile loading.
xbmc/…/ITransportLayer.hDefines transport capabilities used by JSON-RPC operations.
xbmc/…/TCPServer.cppShows stream request handling and remote announcement delivery.
xbmc/…/HTTPJsonRpcHandler.cppShows the HTTP /jsonrpc entry point and its permissions.
xbmc/…/XBPython.cppShows Python runtime setup, callbacks, announcements, and shutdown.
xbmc/…/ScriptInvocationManager.cppShows language-neutral script tracking and control.
xbmc/…/README.mdExplains generated Python modules and binding constraints.
xbmc/interfaces/swig/kodi_common.iDefines the shared rules and types used by Kodi's generated Python modules.
xbmc/…/LibraryBuiltins.cppShows library update, clean, export, search, and refresh commands.
xbmc/…/PlayerBuiltins.cppShows playback, playlist, seek, subtitle, and disc commands.
xbmc/…/ModuleXbmc.hDefines key compatibility-facing Python functions.
xbmc/…/ModuleXbmc.cppShows built-in and local JSON-RPC calls from the legacy Python API.
xbmc/…/InfoTagPicture.cppShows picture metadata access and validation for add-ons.
xbmc/…/InfoTagGame.hDefines the structured game metadata contract exposed to Python add-ons.
xbmc/…/InfoTagGame.cppShows game metadata access and updates through the legacy Python layer.
xbmc/…/InfoTagVideo.cppShows structured media metadata and stream integration for add-ons.
xbmc/…/ListItem.cppShows older list-item metadata paths and their migration to tag objects.