#api-client #unifi #ubiquiti #api

rustifi

Open source Rust library to interface with Ubiquiti's UniFi Controller API

7 releases (1 stable)

1.0.0 Feb 10, 2026
0.4.0 Jul 24, 2025
0.3.0 May 4, 2025
0.2.2 Feb 8, 2025
0.1.0 Jan 26, 2025

#1432 in Network programming

GPL-2.0-only

220KB
5.5K SLoC

rustifi

A Rust API library for UniFi Network controllers.

Quick Start

use rustifi::UnifiClient;

#[tokio::main]
async fn main() -> rustifi::Result<()> {
    // Create a client with strict TLS validation (recommended)
    let client = UnifiClient::with_api_key(
        "https://unifi.example.com",
        "your-api-key"
    )?;

    // Fetch all sites
    let sites = client.request::<rustifi::api::sites::GetSites>().await?;
    for site in sites.data {
        println!("Site: {} ({})", site.name, site.id);
    }

    Ok(())
}

TLS Certificate Handling

By default, rustifi uses strict TLS validation and requires valid certificates.

For Controllers with Valid Certificates

Use the standard constructors:

// These require valid TLS certificates
let client = UnifiClient::new("https://unifi.example.com")?;
let client = UnifiClient::with_api_key("https://unifi.example.com", "api-key")?;

For Local Controllers with Self-Signed Certificates

Many local UniFi controllers use self-signed certificates. For these, use the _insecure variants:

// WARNING: Only use for local controllers on trusted networks
let client = UnifiClient::new_insecure("https://192.168.1.1")?;
let client = UnifiClient::with_api_key_insecure("https://192.168.1.1", "api-key")?;

Security Warning: The _insecure methods disable TLS certificate validation, which makes connections vulnerable to man-in-the-middle attacks. Only use these methods for local controllers on trusted networks.

WORK IN PROGRESS

To Do

  • Implement some access points
  • Implement some switches
  • Ensure compliance with Rust API Guidelines Checklist, Including traits
    • Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Display, Default
    • From, TryFrom, AsRef, AsMut
    • Errors
  • Link capacity on uplinks
  • Tests
  • Documentation
  • Examples

Layout & Features

  • Devices
    • Basic Information
      • Get
      • Update
    • AP
      • Group
      • Model
      • Name
      • Radio
        • Channel
        • Width
        • Power
        • Meshing
      • Number of Clients
      • CPU
      • Memory
    • SW
      • Name
      • Model
      • Port
        • Number
        • Type
        • Status
        • Uptime
        • Bytes
        • Packets
        • Dropped
        • Errors
        • Native VLAN
        • Allowed VLANs
        • Port Isolation
      • CPU
      • Memory
  • Clients
    • Type
    • Impose Punishment
    • Ban
  • WiFi
  • Network

Models

APs

  • UX
  • NanoHD
  • U7-Pro
  • U7-Pro-Max
  • U6-Mesh
  • UWB-XG
  • UAP-XG
  • AC-Mesh
  • AC-Mesh-Pro
  • AC-Pro

Switch

  • USW-Pro-Aggregation
  • USW-Aggregation

License

This project is licensed under GNU General Public License v2.0 (GPL-2.0-only).

Dependencies

~7–23MB
~249K SLoC