Skip to main content

PyKodi

An async python interface for Kodi over JSON-RPC. This is mostly designed to integrate with HomeAssistant. If you have other needs, there might be better packages available.

Installation

You can install PyKodi from PyPI:

pip3 install pykodi

Python 3.11 and above are supported.

How to use

from pykodi import get_kodi_connection, Kodi
kc = get_kodi_connection(<host>, <port>, <ws_port>, <username>, <password>, <ssl>, <timeout>, <session>)
# if ws_port is None the connection will be over HTTP, otherwise over WebSocket.
# ssl defaults to False (only relevant if you have a proxy), timeout to 5 (seconds)
# session is generated if not passed in

# you can also pass in your own session
await kc.connect()

kodi = Kodi(kc)

await kodi.ping()
properties = await kodi.get_application_properties(["name", "version"])

await kodi.play()
await kodi.volume_up()
await kodi.pause()
...

# over WebSocket you can subscribe to Kodi notifications
def on_play(sender, data):
    print(data["item"])

unsubscribe = kc.subscribe("Player.OnPlay", on_play)
...
unsubscribe()

# and get a call when the connection is lost, but not after close()
def on_disconnect(error):
    print("Connection to Kodi lost:", error)  # usually None, a network drop included

remove = kc.on_disconnect(on_disconnect)
...
remove()

Errors

from pykodi import ProtocolError, TransportError, is_error_response, is_unauthorized

try:
    players = await kodi.get_players()
except ProtocolError as error:
    is_error_response(error)  # True if Kodi answered with a JSON-RPC error object
except TransportError as error:
    is_unauthorized(error)    # True if the web server rejected the login (HTTP 401)

Stream and HDR details

players = await kodi.get_players()
info = await kodi.get_stream_info(players[0])

info["currentvideostream"]                  # {"codec": "hevc", "width": 3840, "height": 2160, ...}
info["infolabels"]["VideoPlayer.HdrType"]   # "dolbyvision", "hdr10", "hlg" or "" ("hdr10plus" from Kodi 22)
info["infolabels"]["System.ScreenResolution"]
info["hdrhints"]                            # ["dolbyvision", "hdr10"], taken from the file and folder name

The info labels are returned as Kodi reports them. Labels that the running Kodi version does not know are empty strings. hdrhints lists the HDR formats named in the file name or in the name of the folder that holds the file (not for plugin sources), because Kodi 21 reports HDR10+ as hdr10 and does not report the HDR10 base layer of a Dolby Vision stream.

Metadata

Release files for pykodi 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pykodi 0.5.0
File Size Uploaded Provenance Actions
pykodi-0.5.0.tar.gz 26.7 kB With provenance Details for pykodi-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pykodi 0.5.0
File Interpreter ABI Platform Actions
pykodi-0.5.0-py3-none-any.whl Python 3 none any Details for pykodi-0.5.0-py3-none-any.whl

Total release size: 38.5 kB

Release files / pykodi-0.5.0.tar.gz

Download URL pykodi-0.5.0.tar.gz
Size 26.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cf3d2f476f6755e0170288a1d10047bff4bff567b304b24247e8b0f7e2248b90
BLAKE2b-256 checksum
How to use checksums
7116736336ae2c8b703ea03653479e0ba62d5ab737d815eb81107bbe262e8b70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / pykodi-0.5.0-py3-none-any.whl

Download URL pykodi-0.5.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa632dc0025abc88dbe3e6e70d34411084533831a106a6bce21a4e2837383e42
BLAKE2b-256 checksum
How to use checksums
acbd7433b4705afa383517278428e43554c88f11add94d29d8ea8e8f80618672
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for pykodi 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pykodi-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page