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
For a higher-level abstraction with reactive data streams and automatic data merging, see unifly-core.
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.