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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zmk_studio_api-0.4.0.tar.gz (46.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

zmk_studio_api-0.4.0-cp39-abi3-win_amd64.whl (227.0 kB view details)

Uploaded CPython 3.9+Windows x86-64

zmk_studio_api-0.4.0-cp39-abi3-win32.whl (220.4 kB view details)

Uploaded CPython 3.9+Windows x86

zmk_studio_api-0.4.0-cp39-abi3-manylinux_2_34_x86_64.whl (390.7 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ x86-64

zmk_studio_api-0.4.0-cp39-abi3-macosx_11_0_arm64.whl (350.6 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

zmk_studio_api-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl (346.0 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file zmk_studio_api-0.4.0.tar.gz.

File metadata

  • Download URL: zmk_studio_api-0.4.0.tar.gz
  • Upload date:
  • Size: 46.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for zmk_studio_api-0.4.0.tar.gz
Algorithm Hash digest
SHA256 0a43fb7e8b919f28485b9bed096b0a65ac83c57878b4e22b3b42b9cb4d7a8fbf
MD5 4b0a6e5d2b5ac689e9626cbdc46e4277
BLAKE2b-256 29eabfce80b2ebfc37fa77bd90b4dd231e5ab458395d907258248261cf379e76

See more details on using hashes here.

File details

Details for the file zmk_studio_api-0.4.0-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for zmk_studio_api-0.4.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 83560d45d92a4f502429ca14789f357fd5a6f579e8d69deb255668073d8ba838
MD5 04dfebecbe9c2187804a24da84c6403f
BLAKE2b-256 3302fe9450f63adf5f89d0d9d16326ff493a358b54a12a1f0425dc3b287523cf

See more details on using hashes here.

File details

Details for the file zmk_studio_api-0.4.0-cp39-abi3-win32.whl.

File metadata

File hashes

Hashes for zmk_studio_api-0.4.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 6fb502789f1522853b74057c89fa9643f9968516c353fd0c10f1f9daec9b2d3b
MD5 f3785363efa06b35aa65164644ba7d30
BLAKE2b-256 7edeae6c88bc98de8c498f0660eab311c52ea8246abddebd86602da40ac8047b

See more details on using hashes here.

File details

Details for the file zmk_studio_api-0.4.0-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for zmk_studio_api-0.4.0-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 68fc4e9a5942009df3bd5949226c1478941c0c2fd8446fa290c37cbf0759003d
MD5 51e7260d8c4ee4e4811652b703e8b81e
BLAKE2b-256 63441a2688ee1521bd1d750d5bfb7837cfae73a798c2962aa06198dcebb8ed3e

See more details on using hashes here.

File details

Details for the file zmk_studio_api-0.4.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for zmk_studio_api-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 67aeaff432c3729aac493fa5851f52a0e764b2e02c5a13eef5f22e1cf0dc9285
MD5 e24bce0ce94162c9b12bd3a979149efd
BLAKE2b-256 6d184cd9f8b5762a0b795fa455b2532a40bad50c9ad1cb4b6bd59d44a8601064

See more details on using hashes here.

File details

Details for the file zmk_studio_api-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for zmk_studio_api-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dfb89ebfacfafe4f7b6e3e164df6e1b4c6324740f6cb9ea20f72c5f51b06b59d
MD5 caa806753cfff11e1a704d9393c523c6
BLAKE2b-256 32b6ce00ce9c8ed2396a025ad6ad7a9206943af18a756580346006f14c276f5a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page