unifly-api
Async Rust client for UniFi controller APIs.
Overview
unifly-api provides the HTTP transport layer for communicating with Ubiquiti UniFi Network controllers. It supports two distinct API surfaces:
- Integration API — RESTful OpenAPI-based interface authenticated via
X-API-KEYheader. Primary surface for CRUD operations on devices, clients, networks, firewall rules, and other managed entities. - Legacy API — Session/cookie-authenticated endpoints under
/api/s/{site}/. Used for data not yet exposed by the Integration API: events, traffic stats, admin users, DPI data, system info, and real-time WebSocket events.
Both clients share a common TransportConfig for reqwest-based HTTP transport with configurable TLS verification (system CA, custom PEM, or danger-accept for self-signed controllers) and timeout settings.
Features
- Integration API client with API key authentication
- Legacy API client with cookie/CSRF token handling
- WebSocket event stream with auto-reconnect
- Configurable TLS modes (system CA, custom CA bundle, danger-accept-invalid)
- Async/await with
tokioruntime - Comprehensive error types with context
- Support for UniFi OS and standalone controller platforms
Quick Example
use ;
use SecretString;
async
This crate also includes the high-level Controller with reactive DataStore and EntityStream for automatic data merging and live subscriptions. See the docs for the full API.
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.