Skip to main content

zmk-studio-api

Version image image

zmk-studio-api is a Rust client for the ZMK Studio RPC API on ZMK keyboards. It can read device and keymap state, and apply keymap changes over serial or BLE. Additionally, this library includes Python bindings for API access from Python applications and scripts.

Usage

Rust

Add dependency with Cargo:

cargo add zmk-studio-api [--features ble]

Usage example:

use zmk_studio_api::{Behavior, HidUsage, Keycode, StudioClient, transport::serial::SerialTransport};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = StudioClient::new(SerialTransport::open("COM3")?);
    let info = client.get_device_info()?;
    println!("Device: {}", info.name);
    println!("Lock: {:?}", client.get_lock_state()?);

    let before = client.get_key_at(0, 12)?;
    println!("Before: {before:?}");

    client.set_key_at(0, 12, Behavior::KeyPress(HidUsage::from_encoded(Keycode::A.to_hid_usage())))?;
    let after = client.get_key_at(0, 12)?;
    println!("After: {after:?}");

    if client.check_unsaved_changes()? {
        client.discard_changes()?;
    }
    Ok(())
}

For a complete runnable example, see examples/basic_example.rs.

Python

Install from PyPI:

pip install zmk-studio-api

Usage example:

import zmk_studio_api as zmk

client = zmk.StudioClient.open_serial("COM3")
print("Lock:", client.get_lock_state())

before = client.get_key_at(0, 12)
print("Before:", before)

client.set_key_at(0, 12, zmk.KeyPress(zmk.Keycode.A))
after = client.get_key_at(0, 12)
print("After:", after)

For a complete runnable example, see examples/basic_example.py.

License & Attribution

This project is licensed under the Apache 2.0 license. Parts of this project are based on code from the ZMK Studio (Apache 2.0) and its TypeScript client implementation (MIT).

Metadata

Release files for zmk-studio-api 0.6.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 zmk-studio-api 0.6.0
File Size Uploaded
zmk_studio_api-0.6.0.tar.gz 61.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for zmk-studio-api 0.6.0
File
zmk_studio_api-0.6.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
zmk_studio_api-0.6.0-cp39-abi3-win32.whl CPython 3.9 abi3 Windows x86-32 Details
zmk_studio_api-0.6.0-cp39-abi3-manylinux_2_34_x86_64.whl CPython 3.9 abi3 Linux glibc 2.34+ x86-64 Details
zmk_studio_api-0.6.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
zmk_studio_api-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 1.7 MB

Release files / zmk_studio_api-0.6.0.tar.gz

Download URL zmk_studio_api-0.6.0.tar.gz
Size 61.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a802f96b057a594af2c3a2c1570735f4034054d0c11317fd4d2f357c42efecc5
BLAKE2b-256 checksum
How to use checksums
50169e1b7f9990f16b2e3fbc4cd49b3d0ea745e163abf2ea8888ab0eceeed8d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / zmk_studio_api-0.6.0-cp39-abi3-win_amd64.whl

Download URL zmk_studio_api-0.6.0-cp39-abi3-win_amd64.whl
Size 243.1 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
58a9e413f4d295e58c612c78df785704845c620c113a024d2bc34889952e1e86
BLAKE2b-256 checksum
How to use checksums
828935bd036a1d02afea44ef1cfda9a2a74c541295566e844f789672f45e99e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / zmk_studio_api-0.6.0-cp39-abi3-win32.whl

Download URL zmk_studio_api-0.6.0-cp39-abi3-win32.whl
Size 233.5 kB
Tags CPython 3.9 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
fefeb96c6f24ec593dde26a9d3f454989142169d2b8e779b4b38deb83c2621f5
BLAKE2b-256 checksum
How to use checksums
31f3469e8b785d77fcfcaee1cfa3889d7b489cdcc947c71dac8d7ee0b473a51d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / zmk_studio_api-0.6.0-cp39-abi3-manylinux_2_34_x86_64.whl

Download URL zmk_studio_api-0.6.0-cp39-abi3-manylinux_2_34_x86_64.whl
Size 403.2 kB
Tags CPython 3.9 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
33d704e60a4ea1e0b43d4c4ae5a73107ac27102b286d59e34298c80805fcf775
BLAKE2b-256 checksum
How to use checksums
3a8cc165e45e509c80972b1bcf08b6ddb710991d3476cb9dc6a1ee777e1af0ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / zmk_studio_api-0.6.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL zmk_studio_api-0.6.0-cp39-abi3-macosx_11_0_arm64.whl
Size 363.6 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
51295dd0c33ff8b2f07bc8dc6dbe7617a30e3b41cfffabca998bdf8ba41de3c1
BLAKE2b-256 checksum
How to use checksums
503006b7a6146b798d248cc3cf70ca73f474af2db4ce2557d5895110168ffc1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / zmk_studio_api-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL zmk_studio_api-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 353.9 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
eeec799156abddf9b15714eb3ca8abd156e2dc5e1e4c9b88b487128762102a90
BLAKE2b-256 checksum
How to use checksums
ed404c4b224a4b9b01643a02b84451e34f6dc84bf45305e92d1540e3a7773ef2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release history Release notifications | RSS feed

0.6.1

6 release files

This release

0.6.0 This release

6 release files

0.5.2

6 release files

0.5.1

6 release files

0.5.0

6 release files

0.4.0

6 release files

0.3.1

6 release files

0.3.0

6 release files

0.2.0

6 release files

0.1.1

6 release files

0.1.0

6 release files

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