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.5.1.tar.gz (55.8 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.5.1-cp39-abi3-win_amd64.whl (238.8 kB view details)

Uploaded CPython 3.9+Windows x86-64

zmk_studio_api-0.5.1-cp39-abi3-win32.whl (229.5 kB view details)

Uploaded CPython 3.9+Windows x86

zmk_studio_api-0.5.1-cp39-abi3-manylinux_2_34_x86_64.whl (398.4 kB view details)

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

zmk_studio_api-0.5.1-cp39-abi3-macosx_11_0_arm64.whl (361.3 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

zmk_studio_api-0.5.1-cp39-abi3-macosx_10_12_x86_64.whl (351.4 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for zmk_studio_api-0.5.1.tar.gz
Algorithm Hash digest
SHA256 2a664e6ad6e82ae8cc6f493abdd737e4685bff06478185ef7f911d9bf896c4a9
MD5 867c9ec061c0940eff69ff643af76d33
BLAKE2b-256 71eaeb5d0c4d6a8995bf8b5ed646273a49782912d58ef84d7ba8bf79186b0cc1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zmk_studio_api-0.5.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d6779e352f40d7a0422c2b1cdd3f095505496a2bc261e4575ce4c709ff205101
MD5 5d565d0b967bb6af64caddfc9fa90539
BLAKE2b-256 b476cce3d34f26b4af502c4fb748cf776e458c3de46067aeb8c051436fa04531

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zmk_studio_api-0.5.1-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 41ece73ff96cbce77f18f9e45095e2aca0a4659e47eab4555c0f092ca8a9e142
MD5 0021b4c5c03625bfb8ccf0e78e6b2244
BLAKE2b-256 9a2bcd4f1fa7eef51d2108e21eff071fb45e63c6694f866a3aafdb291b7c3d14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zmk_studio_api-0.5.1-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 229a481fd247ebcf12f956648f53badba924da2ae3888d6f43d6f70dab108271
MD5 4c425f4384f5f99d35589c9d30bb2664
BLAKE2b-256 8043a01d457a9e510984719f2607e56b6cd492b7cad0b669445353ef84a9a8a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zmk_studio_api-0.5.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c1cfe4ebce17bae545e02459a54f5bd7804e41f975263ebac5cbef18789985c
MD5 e040bace7f5e19de1e8df2cacf2eb8e0
BLAKE2b-256 5f1d3da461b92093eb00a7eafc50e94b69c7c0b93e8204901df0c06f2be528d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zmk_studio_api-0.5.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 009d359374fe067b00a84f8db7c9781c33368f637d8b35be0cec2718bfb55e3f
MD5 36f80037528da232fab769969cc963f4
BLAKE2b-256 05704000b74fca3a199eb98f6f1c0ab132ee7dbcb8725cc641181bcdf3a6bfff

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