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
System Device info, service logs, realtime log streaming
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.2.1.tar.gz (93.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.2.1-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aiopikvm-0.2.1.tar.gz
Algorithm Hash digest
SHA256 84003bc4660fb30b6b84095e720d3a06235bef0024b0a074ca14e7705936acdf
MD5 df508c864750859a7a335143f401434a
BLAKE2b-256 55923580817f08a00a285b1e449ddbdeacdba8911d46c2ed02b5722ded86ab6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiopikvm-0.2.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.2.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for aiopikvm-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5be99e6fe429b6350c4873760e631478f5219cb69fd83b8548ac77ad434a9476
MD5 2369f347d61d260cc9376f6227d0dfd0
BLAKE2b-256 6e8045a51b279e4a9d94b993a290b72b1f7213f333f9e747026199e72a3ec28c

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiopikvm-0.2.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