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.0.tar.gz (56.1 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.0-cp39-abi3-win_amd64.whl (238.0 kB view details)

Uploaded CPython 3.9+Windows x86-64

zmk_studio_api-0.5.0-cp39-abi3-win32.whl (230.7 kB view details)

Uploaded CPython 3.9+Windows x86

zmk_studio_api-0.5.0-cp39-abi3-manylinux_2_34_x86_64.whl (396.3 kB view details)

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

zmk_studio_api-0.5.0-cp39-abi3-macosx_11_0_arm64.whl (360.0 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

zmk_studio_api-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl (352.3 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for zmk_studio_api-0.5.0.tar.gz
Algorithm Hash digest
SHA256 09e63ad56dc30904bd6d3ad9b978c407296407befe70dbbcf7e253ce82260ce0
MD5 211703ff53a245fdd288d4b186143605
BLAKE2b-256 3343a7da05da1fa14ed4d531179c94844cd87f3e1b90c0042914fd41dbfac9c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zmk_studio_api-0.5.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 822d882a5a396fa6d8458dbfe053fcc7cab05f740cc455993b6199888f775fbc
MD5 ef32edfcdde900f8779a4071dcc8d3e6
BLAKE2b-256 fd03295720b569c23884a1907e5f348dfe1b5285e03220e0c9b47db30c42d2ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zmk_studio_api-0.5.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 8080d68102162e708b5ceb6446a4293a279cc5fa5048079528e28f23f0beb547
MD5 1909da0f8d099f3db147b4e07e8a1a0b
BLAKE2b-256 51e473f4d00d2e44c343723aba35ae173ebe7493e6adb68a07bf3a96e19fa189

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zmk_studio_api-0.5.0-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1ed2b2e141afdbd13845060e50f11d5e99f89e7ffd1ecb8e162e672c70885139
MD5 4e14bcc9b7714af2a8175fc3bb6fe8cb
BLAKE2b-256 9ea1509692cb0ecb944feb677ba3f313e124468127ad3fe5dda96d3acb07311d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zmk_studio_api-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 93ce349358b1487d618f76fd56e78c2b9a2bdaacc925f67ca7dd66e9db62cb6e
MD5 f194045fd495826df1a2588f8750ff92
BLAKE2b-256 fbb2e74b8dbae2f7ab56cafb68e7f0b213ed569c0d9afaf75349a0a340b5f7ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zmk_studio_api-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 98be776112dc25846e2426f1b43912c341f81ef4173ba8e9536b074f4c9f66fd
MD5 24a46f2028bc8284d8e03222723b9904
BLAKE2b-256 dbd72d63f1c40894cf2926b5707d50c6834981464b35c441f7b27edb2b3fd8f6

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