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.5.2

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.5.2
File Size Uploaded
zmk_studio_api-0.5.2.tar.gz 55.9 kB Details

Built distributions (wheels)

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

Total release size: 1.6 MB

Release files / zmk_studio_api-0.5.2.tar.gz

Download URL zmk_studio_api-0.5.2.tar.gz
Size 55.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b14d17a3223911b5d50a5ff7af004b31bef6357d01acbc2b8414696be2e6164a
BLAKE2b-256 checksum
How to use checksums
b181b2b81ac898e538afc1cc107bb3e43efe29b1a2c668b235ea3b002ce95a08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

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

Download URL zmk_studio_api-0.5.2-cp39-abi3-win_amd64.whl
Size 241.1 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5e15b8477a176a56ff9b4d1f268403ed9ffe82934969d854b8a4ae28ce55170d
BLAKE2b-256 checksum
How to use checksums
348137520dba7519988095f34b25eba6fc4e746a9c6e20813219d2784c8ea456
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

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

Download URL zmk_studio_api-0.5.2-cp39-abi3-win32.whl
Size 231.9 kB
Tags CPython 3.9 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
81d839e974ce602b835386dbdc2040f651dd404904f1b85b24b7252a754091d6
BLAKE2b-256 checksum
How to use checksums
18697f004889f633b01cee0a0b9a6bba40068603a12350649851b1b2e924a90f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

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

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

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

Download URL zmk_studio_api-0.5.2-cp39-abi3-macosx_11_0_arm64.whl
Size 361.2 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9b41a533bd248f2b6e67f6eb1d0e31909def0551292f7c9323299b3649eeb857
BLAKE2b-256 checksum
How to use checksums
a3d589ca8d1a1fc3a5ab8a0d8b585786b276637bd6ff10c94da383e7c90062f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

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

Download URL zmk_studio_api-0.5.2-cp39-abi3-macosx_10_12_x86_64.whl
Size 351.7 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d7c4067dcf681c0c1520063759b0cc02496b0931f55b3458bf99a045bea2678f
BLAKE2b-256 checksum
How to use checksums
cfe0a4dcd05cf742a60490475fab99525ee906bebabb0b073bb98d5f6b01933a
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

0.6.0

6 release files

This release

0.5.2 This release

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