Async Python client for PiKVM API
Project description
aiopikvm
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.AsyncClientsupport 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b1d66d14ec6daa753fd5a30e5fc4f684063495b7f2db8c0dcab684c2a48a4e3
|
|
| MD5 |
532d4f94c4d28c5457954333b8e4ea8a
|
|
| BLAKE2b-256 |
622aa572a806a2156c4c77d4902fdda91744d3446b098a2ce1d8a512c7aba218
|
Provenance
The following attestation bundles were made for aiopikvm-0.1.1.tar.gz:
Publisher:
release.yml on kudato/aiopikvm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiopikvm-0.1.1.tar.gz -
Subject digest:
9b1d66d14ec6daa753fd5a30e5fc4f684063495b7f2db8c0dcab684c2a48a4e3 - Sigstore transparency entry: 953692759
- Sigstore integration time:
-
Permalink:
kudato/aiopikvm@bf85381311a9e1f4ece972712d3453c734e0c72a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/kudato
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bf85381311a9e1f4ece972712d3453c734e0c72a -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a9e349f9154c5919d164da4e17f4e2ed3b52ac575dae85ea81f012c04c1a18e
|
|
| MD5 |
5609dc0fdccffc78a070b678fea1b8e4
|
|
| BLAKE2b-256 |
1627340d49410477acce1fa0edb2d8025347c8df1c17b6d6c801407aba60df59
|
Provenance
The following attestation bundles were made for aiopikvm-0.1.1-py3-none-any.whl:
Publisher:
release.yml on kudato/aiopikvm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiopikvm-0.1.1-py3-none-any.whl -
Subject digest:
2a9e349f9154c5919d164da4e17f4e2ed3b52ac575dae85ea81f012c04c1a18e - Sigstore transparency entry: 953692874
- Sigstore integration time:
-
Permalink:
kudato/aiopikvm@bf85381311a9e1f4ece972712d3453c734e0c72a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/kudato
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bf85381311a9e1f4ece972712d3453c734e0c72a -
Trigger Event:
push
-
Statement type: