Rust + Python client for the ZMK Studio RPC API (Serial + BLE)
Project description
zmk-studio-api
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).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zmk_studio_api-0.3.1.tar.gz.
File metadata
- Download URL: zmk_studio_api-0.3.1.tar.gz
- Upload date:
- Size: 46.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcb2d861af2a8a7a76a4e760cd43a6a4a84d84442d45e65eae0e9bb976fe98e7
|
|
| MD5 |
d8245fde98acd2556860e816168b58f9
|
|
| BLAKE2b-256 |
7c34970d25c80043cf702cef72228a3d0a7a148568223cd6da8bb21e7c4f41ea
|
File details
Details for the file zmk_studio_api-0.3.1-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: zmk_studio_api-0.3.1-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 232.2 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f6e0899723cb5eed0b11e92d6e93ede9fa39e299f8dc7f32b628530da125d2e
|
|
| MD5 |
dcd9d27bcc2c8845d26024dcd6cb4c56
|
|
| BLAKE2b-256 |
76c3cc3fa75a8e494d1f04763e798397044bc2b3fdd7be96d22b1570457878f3
|
File details
Details for the file zmk_studio_api-0.3.1-cp39-abi3-win32.whl.
File metadata
- Download URL: zmk_studio_api-0.3.1-cp39-abi3-win32.whl
- Upload date:
- Size: 224.7 kB
- Tags: CPython 3.9+, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d59f45bb6b27be4a759efe67e8e4b2bf27685825255e4caeb6ed472d8a5cd37
|
|
| MD5 |
723eea20dac8860cd3fc1b3cfc10673f
|
|
| BLAKE2b-256 |
188e557276d06fe6e9e02990977541b58f2fea5689ba40264ad5b8da614cbc20
|
File details
Details for the file zmk_studio_api-0.3.1-cp39-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: zmk_studio_api-0.3.1-cp39-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 406.2 kB
- Tags: CPython 3.9+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fc84a9a24eeb2777e2979439512034fb15ddd3b1c6c166b86383d8e9a34928d
|
|
| MD5 |
eb7899559bc74100dd98474164612f4d
|
|
| BLAKE2b-256 |
5fb0ec028e91a9d22062912bd4e028889f43d31fbec75630f71950a482b713a6
|
File details
Details for the file zmk_studio_api-0.3.1-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: zmk_studio_api-0.3.1-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 357.8 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d748612a403ab3af37ead3cf6c2b0c710b8ed48143d130949ed3320869888888
|
|
| MD5 |
bf173dfc659b1a7c388054a70b2d9c0f
|
|
| BLAKE2b-256 |
a5f7e1d5859a21c9745154972a2539a7ae7209f23014d1c62c46d1ee83da1d55
|
File details
Details for the file zmk_studio_api-0.3.1-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: zmk_studio_api-0.3.1-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 360.7 kB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fecac798092a5657937fade1496d24178fed3dbc59a065e8b2653cbedf4bd5b
|
|
| MD5 |
e882ba803b02477df4ec770cd5d63d09
|
|
| BLAKE2b-256 |
6a5cbf36f7a3d249ad691ceb6f6c07603a0b2253700f43057e7d449d739f53b1
|