Crate unifi_access

Source
Expand description

§Unifi Access API Client

This crate provides a client for the Unifi Access API based off of the documentation found here:

https://core-config-gfoz.uid.alpha.ui.com/configs/unifi-access/api_reference.pdf

This crate is a hand written wrapper of the described REST API, and is incomplete in coverage at the moment. This crate was developed to support a Makerspace door access system and is being happily used in production for that application.

Contributions to extend the functionality are welcome.

To get started login to your Unifi Controller and go to: Settings -> Security -> Advanced and create a new token. There is a link to the documentation for the API alongside the token.

The API is only available on the LAN network of the controller, if you want to access the API from offsite you’ll need to establish a VPN.

A basic example:

use unifi_access::UnifiClient;
#[tokio::main]
async fn main() {
  let client = UnifiClient::new("192.168.1.1", "your_auth_token");
  let users = client.get_all_users().await.unwrap();
  println!("{users:?}");
}

Head to UnifiClient to see the available operations.

The API is fully async and technically relies on tokio, but tokio could be removed if folks want a different runtime.

Structs§

AccessPolicy
Represents an access policy in the unifi system
Device
Represents a physical device within the building
NfcCard
Represents an NFC card in the unifi system.
SystemLogEvent
An individual entry in the unifi system log
SystemLogEventWrapper
Weirdly nested structure returned by the system log endpoint
SystemLogResponse
Full response from system log endpoint
UnifiClient
The base client object that operations are provided on.
User
Represents a user in the unifi system. This is used with serde_json to serialize and deserialize the JSON responses from the API.
UsersResponse
The response format for a list of users

Enums§

SystemLogTopic
The available system log topics within unifi