qmk-via-api provides an implementation of the VIA API for QMK (Quantum Mechanical Keyboard) based keyboards. It allows developers to interact with QMK keyboards programmatically, enabling tasks such as configuring keymaps, macros, lighting effects and more.
Additionally, this library includes Python bindings for all API calls for integration of QMK keyboard configuration into Python-based applications or scripts.
Add dependency with Cargo:
cargo add qmk-via-apiUsage example:
use qmk_via_api::{api::KeyboardApi, scan::scan_keyboards};
fn main() {
if let Some(dev) = scan_keyboards().first() {
let api = KeyboardApi::new(dev.vendor_id, dev.product_id, dev.usage_page).unwrap();
println!("Protocol version: {:?}", api.get_protocol_version());
println!("Layer count: {:?}", api.get_layer_count());
} else {
println!("No devices found");
}
}The python feature flag is enabled by default. In projects that don't interoperate with Python, the Python bindings can be disabled by turning off default features. In Cargo.toml:
[dependencies]
qmk-via-api = { version = "0.3.0", default-features = false }Install with pip:
pip install qmk-via-apiUsage example:
import qmk_via_api
from qmk_via_api import scan_keyboards
devices = scan_keyboards()
if devices:
dev = devices[0]
api = qmk_via_api.KeyboardApi(dev.vendor_id, dev.product_id, dev.usage_page)
print(f"Protocol version {api.get_protocol_version()}")
print(f"Layers count: {api.get_layer_count()}")
else:
print("No devices found")Parts of this project are based on code from the VIA project, which is licensed under the GNU General Public License v3.0.