#protect #unifi #server #sdk #camera #api #system

unifi_protect

An SDK for interacting with a unifi protect server

16 unstable releases (3 breaking)

0.5.2 Feb 16, 2024
0.5.1 Feb 16, 2024
0.4.9 Feb 16, 2024
0.4.8 Aug 11, 2023
0.1.3 Jul 23, 2023

#1681 in Web programming

Download history 394/week @ 2024-02-16 54/week @ 2024-02-23 24/week @ 2024-03-01 5/week @ 2024-03-08 11/week @ 2024-03-15 1/week @ 2024-03-22 38/week @ 2024-03-29 3/week @ 2024-04-05 181/week @ 2024-04-12

223 downloads per month
Used in unifi-protect-bulk-downlo…

GPL-3.0 license

29KB
791 lines

UniFi-Protect Rust Library

Crates.io Docs.rs Build Status

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());

Dependencies

~6–20MB
~293K SLoC