Skip to main content

Crate unifly_api

Crate unifly_api 

Source
Expand description

Async Rust client and reactive data layer for UniFi controller APIs.

This crate provides both the HTTP transport layer and the domain model for communicating with UniFi Network controllers.

§Transport layer

  • Integration API (IntegrationClient) — RESTful OpenAPI-based interface authenticated via X-API-KEY header. Primary surface for CRUD operations on devices, clients, networks, firewall rules, and other managed entities.

  • Legacy API (LegacyClient) — 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 (TlsMode: system CA, custom PEM, or danger-accept for self-signed controllers) and timeout settings.

§Domain layer

  • Controller — Central facade managing the full lifecycle: authentication, background refresh, and command routing.

  • DataStore — Lock-free reactive storage built on DashMap + watch channels.

  • EntityStream<T> — Subscription handle for TUI reactive rendering.

  • Domain model (model) — Canonical types (Device, Client, Network, FirewallPolicy, Event, etc.) with EntityId supporting both UUID and string-based identifiers.

Re-exports§

pub use auth::AuthStrategy;
pub use auth::ControllerPlatform;
pub use auth::Credentials;
pub use error::Error;
pub use integration::IntegrationClient;
pub use integration::types as integration_types;
pub use legacy::LegacyClient;
pub use legacy::models as legacy_models;
pub use transport::TlsMode;
pub use transport::TransportConfig;
pub use command::Command;
pub use command::CommandResult;
pub use config::AuthCredentials;
pub use config::ControllerConfig;
pub use config::TlsVerification;
pub use controller::ConnectionState;
pub use controller::Controller;
pub use core_error::CoreError;
pub use store::DataStore;
pub use stream::EntityStream;
pub use model::AclRule;
pub use model::Admin;
pub use model::Alarm;
pub use model::Client;
pub use model::ClientType;
pub use model::Country;
pub use model::Device;
pub use model::DeviceState;
pub use model::DeviceType;
pub use model::DpiApplication;
pub use model::DpiCategory;
pub use model::EntityId;
pub use model::Event;
pub use model::EventCategory;
pub use model::EventSeverity;
pub use model::FirewallPolicy;
pub use model::FirewallZone;
pub use model::HealthSummary;
pub use model::MacAddress;
pub use model::Network;
pub use model::RadiusProfile;
pub use model::Site;
pub use model::SysInfo;
pub use model::SystemInfo;
pub use model::TrafficMatchingList;
pub use model::VpnServer;
pub use model::VpnTunnel;
pub use model::WanInterface;
pub use command::requests::*;

Modules§

auth
command
config
controller
convert
core_error
error
integration
legacy
model
store
stream
transport
websocket
WebSocket event stream with auto-reconnect.