This document details the PiKVM REST API endpoints needed for the MCP server implementation.
All API endpoints are prefixed with /api/ when accessed via HTTP(S) on ports 80/443.
When using the Unix socket directly (/run/kvmd/kvmd.sock), omit the /api/ prefix.
Example: https://<pikvm-ip>/api/hid/print
PiKVM supports multiple authentication methods:
curl -k \
-H "X-KVMD-User: admin" \
-H "X-KVMD-Passwd: yourpassword" \
https://<pikvm-ip>/api/auth/checkcurl -k -u admin:yourpassword https://<pikvm-ip>/api/auth/check- Login to get token:
curl -k -c cookies.txt -X POST \
--data "user=admin" \
--data "passwd=yourpassword" \
https://<pikvm-ip>/api/auth/login- Use token in subsequent requests:
curl -k -b cookies.txt https://<pikvm-ip>/api/info| Endpoint | Method | Description |
|---|---|---|
/api/auth/check |
GET | Check if authenticated (200 = yes, 401/403 = no) |
/api/auth/login |
POST | Login with user and passwd form data |
/api/auth/logout |
POST | Invalidate current session |
GET /api/hid
Returns current HID device state including keyboard/mouse connection status.
POST /api/hid/set_params
Parameters:
keyboard_output- Keyboard output modemouse_output- Mouse output modejiggler- Enable mouse jiggler to prevent sleep
POST /api/hid/reset
Resets the HID device. Useful if keyboard/mouse becomes unresponsive.
GET /api/hid/keymaps
Returns list of available keyboard layout mappings (e.g., en-us, de, fr).
POST /api/hid/print
Parameters:
text(body) - The text to typelimit- Maximum characters (default: 1024)keymap- Keyboard layout (default:en-us)slow- Use slow typing mode (boolean)delay- Delay between keystrokes in ms (0-200)
Example:
curl -k -u admin:admin \
-X POST \
-H "Content-Type: text/plain" \
-d "Hello World!" \
"https://<pikvm-ip>/api/hid/print?keymap=en-us"This endpoint handles special character conversion properly via the keymap.
POST /api/hid/events/send_key
Parameters:
key- Key code (e.g.,KeyA,Enter,ShiftLeft)state-true= press,false= release, omit = press+release
Key Codes: Use standard JavaScript key codes:
- Letters:
KeyA,KeyB, ...KeyZ - Numbers:
Digit0,Digit1, ...Digit9 - Function:
F1,F2, ...F12 - Modifiers:
ShiftLeft,ShiftRight,ControlLeft,ControlRight,AltLeft,AltRight,MetaLeft,MetaRight - Special:
Enter,Escape,Backspace,Tab,Space,Delete,Insert,Home,End,PageUp,PageDown - Arrows:
ArrowUp,ArrowDown,ArrowLeft,ArrowRight
Example - Ctrl+Alt+Delete:
# Press Ctrl
curl -k -u admin:admin -X POST "https://<pikvm-ip>/api/hid/events/send_key?key=ControlLeft&state=true"
# Press Alt
curl -k -u admin:admin -X POST "https://<pikvm-ip>/api/hid/events/send_key?key=AltLeft&state=true"
# Press and release Delete
curl -k -u admin:admin -X POST "https://<pikvm-ip>/api/hid/events/send_key?key=Delete"
# Release Alt
curl -k -u admin:admin -X POST "https://<pikvm-ip>/api/hid/events/send_key?key=AltLeft&state=false"
# Release Ctrl
curl -k -u admin:admin -X POST "https://<pikvm-ip>/api/hid/events/send_key?key=ControlLeft&state=false"POST /api/hid/events/send_shortcut
Parameters:
keys- Array of key codes to press simultaneously
Example:
curl -k -u admin:admin \
-X POST \
-H "Content-Type: application/json" \
-d '["ControlLeft", "AltLeft", "Delete"]' \
https://<pikvm-ip>/api/hid/events/send_shortcutIMPORTANT: PiKVM uses a normalized coordinate system internally:
- Absolute coordinates: Range
-32768to32767(signed 16-bit integer) - Relative deltas: Range
-127to127(signed 8-bit integer)
The coordinate (0, 0) maps to the center of the screen in the internal system, but the MCP server converts pixel coordinates automatically.
Conversion formula (pixel to PiKVM):
pikvm_x = remap(pixel_x, 0, screen_width - 1, -32768, 32767)
pikvm_y = remap(pixel_y, 0, screen_height - 1, -32768, 32767)
GET /api/streamer
Returns: JSON with result.source.resolution.width and result.source.resolution.height
POST /api/hid/events/send_mouse_move
Parameters:
to_x- X coordinate (range: -32768 to 32767)to_y- Y coordinate (range: -32768 to 32767)
Note: The MCP server's pikvm_mouse_move tool accepts pixel coordinates and converts them automatically.
POST /api/hid/events/send_mouse_relative
Parameters:
delta_x- Horizontal movement (range: -127 to 127, negative = left, positive = right)delta_y- Vertical movement (range: -127 to 127, negative = up, positive = down)
POST /api/hid/events/send_mouse_button
Parameters:
button-left,right,middle,up, ordown(up/down are scroll wheel buttons)state-true= press,false= release, omit = click
Example - Right click:
curl -k -u admin:admin -X POST "https://<pikvm-ip>/api/hid/events/send_mouse_button?button=right"POST /api/hid/events/send_mouse_wheel
Parameters:
delta_x- Horizontal scrolldelta_y- Vertical scroll (negative = up, positive = down)
GET /api/streamer
Returns current video streamer state.
GET /api/streamer/snapshot
Parameters:
preview- Generate preview image (boolean)preview_max_width- Max width in pixelspreview_max_height- Max height in pixelspreview_quality- JPEG quality (1-100)allow_offline- Allow capture even if no video signal (boolean)ocr- Perform OCR on image (boolean)ocr_langs- OCR languages (comma-separated)ocr_left,ocr_top,ocr_right,ocr_bottom- OCR region
Example - Get screenshot:
curl -k -u admin:admin \
-o screenshot.jpg \
"https://<pikvm-ip>/api/streamer/snapshot"Example - Get resized preview:
curl -k -u admin:admin \
-o preview.jpg \
"https://<pikvm-ip>/api/streamer/snapshot?preview=1&preview_max_width=800&preview_quality=80"Response: Returns JPEG image data directly (Content-Type: image/jpeg)
DELETE /api/streamer/snapshot
GET /api/info
Returns system information including hardware, software versions, etc.
- 200 - Success
- 400 - Bad request (invalid parameters)
- 401 - Unauthorized (not authenticated)
- 403 - Forbidden (authenticated but not allowed)
- 404 - Not found
- 413 - Payload too large (text too long for /hid/print)
- 500 - Internal server error
Error responses are JSON:
{
"ok": false,
"result": {
"error": "Error description"
}
}PiKVM typically uses self-signed certificates. Options:
- Use
-kflag with curl to skip verification - Add PiKVM's CA to your trust store
- Set
rejectUnauthorized: falsein Node.js HTTPS agent