Skip to main content

Async Python client for PiKVM API

Project description

aiopikvm

CI PyPI Python License Docs

Async Python client for the PiKVM API.

Installation

pip install aiopikvm

or with uv:

uv add aiopikvm

Quick start

import asyncio
from aiopikvm import PiKVM

async def main():
    async with PiKVM("https://pikvm.local", user="admin", passwd="admin") as kvm:
        # ATX power control
        state = await kvm.atx.get_state()
        if not state.leds.power:
            await kvm.atx.power_on()

        # HID — type text
        await kvm.hid.type_text("Hello from aiopikvm!")

        # Streamer — take a screenshot
        snapshot = await kvm.streamer.snapshot()
        with open("screen.jpeg", "wb") as f:
            f.write(snapshot)

asyncio.run(main())

Features

API resources

Resource Description
ATX Host power control (power on/off, reset, status LEDs)
HID Keyboard and mouse input, text typing, keymaps
MSD Virtual mass storage drives, image upload
GPIO GPIO channel read/write control
Streamer Video snapshots, OCR
Switch Multi-port KVM switching, EDID management
Redfish DMTF Redfish BMC compatibility interface
Prometheus Metrics export in Prometheus format
WebSocket Realtime events, keyboard/mouse input via WebSocket

Highlights

  • Full async/await API built on httpx
  • Response models powered by Pydantic v2
  • Custom exception hierarchy for precise error handling
  • External httpx.AsyncClient support for advanced use cases
  • TOTP two-factor authentication support
  • WebSocket client for realtime events and low-latency HID input
  • Fully typed (PEP 561, mypy strict)

Configuration

from aiopikvm import PiKVM

kvm = PiKVM(
    "https://pikvm.local",
    user="admin",          # default: "admin"
    passwd="secret",
    totp="123456",         # optional TOTP code
    verify_ssl=False,      # default: False (PiKVM uses self-signed certs)
    timeout=10.0,          # default timeout in seconds
)

External httpx client

import httpx
from aiopikvm import PiKVM

async with httpx.AsyncClient(verify=False) as http:
    async with PiKVM("https://pikvm.local", http_client=http) as kvm:
        state = await kvm.atx.get_state()

When an external client is provided, PiKVM does not close it on exit — the caller is responsible.

WebSocket

async with PiKVM("https://pikvm.local", user="admin", passwd="admin") as kvm:
    async with kvm.ws() as ws:
        # Send keyboard input
        await ws.send_key("KeyA", state=True)
        await ws.send_key("KeyA", state=False)

        # Move mouse
        await ws.send_mouse_move(100, 200)

        # Iterate over realtime events
        async for event in ws.events():
            print(event)

Documentation

Full documentation is available at kudato.github.io/aiopikvm.

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiopikvm-0.1.1.tar.gz (32.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiopikvm-0.1.1-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file aiopikvm-0.1.1.tar.gz.

File metadata

  • Download URL: aiopikvm-0.1.1.tar.gz
  • Upload date:
  • Size: 32.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiopikvm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9b1d66d14ec6daa753fd5a30e5fc4f684063495b7f2db8c0dcab684c2a48a4e3
MD5 532d4f94c4d28c5457954333b8e4ea8a
BLAKE2b-256 622aa572a806a2156c4c77d4902fdda91744d3446b098a2ce1d8a512c7aba218

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiopikvm-0.1.1.tar.gz:

Publisher: release.yml on kudato/aiopikvm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiopikvm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: aiopikvm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiopikvm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a9e349f9154c5919d164da4e17f4e2ed3b52ac575dae85ea81f012c04c1a18e
MD5 5609dc0fdccffc78a070b678fea1b8e4
BLAKE2b-256 1627340d49410477acce1fa0edb2d8025347c8df1c17b6d6c801407aba60df59

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiopikvm-0.1.1-py3-none-any.whl:

Publisher: release.yml on kudato/aiopikvm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page