Skip to main content

unifly_api/
lib.rs

1//! Async Rust client for UniFi controller APIs.
2//!
3//! This crate provides the HTTP transport layer for communicating with UniFi
4//! Network controllers. It supports two distinct API surfaces:
5//!
6//! - **Integration API** ([`IntegrationClient`]) — RESTful OpenAPI-based interface
7//!   authenticated via `X-API-KEY` header. Primary surface for CRUD operations on
8//!   devices, clients, networks, firewall rules, and other managed entities.
9//!
10//! - **Legacy API** ([`LegacyClient`]) — Session/cookie-authenticated endpoints under
11//!   `/api/s/{site}/`. Used for data not yet exposed by the Integration API: events,
12//!   traffic stats, admin users, DPI data, system info, and real-time WebSocket events.
13//!
14//! Both clients share a common [`TransportConfig`] for reqwest-based HTTP transport
15//! with configurable TLS ([`TlsMode`]: system CA, custom PEM, or danger-accept for
16//! self-signed controllers) and timeout settings.
17//!
18//! Higher-level consumers (e.g. `unifly-core`) compose both clients behind a unified
19//! [`Controller`](../unifly_core/struct.Controller.html) facade and merge their
20//! responses into canonical domain types.
21
22pub mod auth;
23pub mod error;
24pub mod integration;
25pub mod legacy;
26pub mod transport;
27pub mod websocket;
28
29pub use auth::{AuthStrategy, ControllerPlatform, Credentials};
30pub use error::Error;
31pub use integration::IntegrationClient;
32pub use integration::types as integration_types;
33pub use legacy::LegacyClient;
34pub use legacy::models as legacy_models;
35pub use transport::{TlsMode, TransportConfig};