Crates.io | unifi_protect |
lib.rs | unifi_protect |
version | 0.5.2 |
source | src |
created_at | 2023-07-23 14:28:18.1379 |
updated_at | 2024-02-16 21:45:32.736128 |
description | An SDK for interacting with a unifi protect server |
homepage | https://github.com/xlfpx/unifi-protect-rust |
repository | https://github.com/xlfpx/unifi-protect-rust |
max_upload_size | |
id | 923778 |
size | 154,568 |
This library enables interacting with a unifi protect server (such as the one running on a ubiquiti cloud key gen2). It aims to eventually be a complete implementation of the unifi protect api in Rust, closely following the example of the javascript-based https://github.com/hjdhjd/unifi-protect/ It is also used in the unifi-protect-bulk-download tool for downloading footage from a unifi protect system.
To add the library to an existing cargo project: cargo add unifi-protect
Basic usage:
use unifi_protect::UnifiProtectServer;
// [ ...]
// within an async context:
// create a new instance using the base uri of the unifi protect server (same uri you would use to reach the system's web portal)
let mut server = UnifiProtectServer::new("BASE_URI"); // ( e.g. "https://192.168.1.28")
// login with username + password credentials (same credentials you would use to login to the system's web portal)
server
.login("USERNAME", "PASSWORD")
.await
.expect("Failed to login");
server
.fetch_cameras()
.await
.expect("Failed to fetch cameras");
println!("Found {} cameras", server.cameras.len());