Chrison.UnifiSharp 0.1.1-preview.4

This is a prerelease version of Chrison.UnifiSharp.
dotnet add package Chrison.UnifiSharp --version 0.1.1-preview.4
                    
NuGet\Install-Package Chrison.UnifiSharp -Version 0.1.1-preview.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Chrison.UnifiSharp" Version="0.1.1-preview.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Chrison.UnifiSharp" Version="0.1.1-preview.4" />
                    
Directory.Packages.props
<PackageReference Include="Chrison.UnifiSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Chrison.UnifiSharp --version 0.1.1-preview.4
                    
#r "nuget: Chrison.UnifiSharp, 0.1.1-preview.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Chrison.UnifiSharp@0.1.1-preview.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Chrison.UnifiSharp&version=0.1.1-preview.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Chrison.UnifiSharp&version=0.1.1-preview.4&prerelease
                    
Install as a Cake Tool

UnifiSharp

NuGet Downloads ci Built with Fallout License: MIT

A C# client for the UniFi Network API โ€” mostly code-generated from Ubiquiti's official OpenAPI spec, with a thin hand-written runtime for auth and transport. Sibling to ProxmoxSharp; built to bring the UniFi-managed network under the homelab's C#-native IaC. See ADR-0003.

dotnet add package Chrison.UnifiSharp

Approach

flowchart LR
  SPEC["๐Ÿ“œ UniFi OpenAPI 3.1<br/>(console / beezly mirror)"] --> KIOTA["โš™๏ธ Kiota (pinned tool)<br/>generate C# client"]
  KIOTA --> API["๐Ÿ“ฆ UnifiSharp.Api<br/>generated ยท tracks UniFi release"]
  API --> RT["โœ๏ธ UnifiSharp<br/>hand-written runtime (X-API-KEY)"]
  RT --> LEG["๐Ÿงฉ UnifiSharp.Legacy<br/>session-auth write adapter<br/>(port-forwards ยท firewall ยท networks)"]
  classDef gen fill:#e0e7ff,stroke:#4f46e5;
  class API gen;

The UniFi spec is already OpenAPI 3.1, so โ€” unlike ProxmoxSharp โ€” there's no converter; Kiota consumes it directly. The generated client is regenerated on build (only when the spec changes) and not committed.

Write coverage caveat (per ADR-0003): the official API is read-mostly today (firewall rules / port profiles not yet exposed; full write rolling out through 2026). Those will be filled by a thin, deletable legacy adapter later. This repo starts read-only.

Projects & versioning

Project What Version
src/UnifiSharp.Api/ Kiota-generated client. Generated/ produced on build (gitignored). Tracks the UniFi Network API release (e.g. 10.4.57).
src/UnifiSharp/ Hand-written runtime (UnifiApi, X-API-KEY auth, options) over .Api. Independent SemVer (0.1.0).
tests/UnifiSharp.Tests/ Unit tests. โ€”

Build

Built with Fallout (Chris's C#/.NET build system, a NUKE successor). Targets: Compile โ†’ Test โ†’ Pack โ†’ Publish.

./build.sh              # default: Test (Compile regenerates UnifiSharp.Api from the spec, then compiles)
./build.sh Pack         # produce the Chrison.* nupkgs into artifacts/

Requires the .NET 10 SDK (see global.json) and GITHUB_PACKAGES_PAT in the environment (a PAT with read:packages on the Fallout-build org โ€” the build restores Fallout.* from that feed, see nuget.config). CI runs ./build.sh Test on push/PR.

Use it

var client = UnifiApi.Create(new UnifiClientOptions
{
    // NOTE: no /v1 โ€” the generated client appends the version segment itself.
    // UniFi OS (Cloud Gateway/UDM/UniFi OS Server):  https://<host>/proxy/network/integration
    // Standalone Network Application:                 https://<host>:8443/integration
    BaseUrl = new Uri("https://192.168.1.1/proxy/network/integration"),
    ApiKey  = "<local API key โ€” Settings โ†’ Integrations>",
    VerifyTls = false,   // self-signed LAN cert
});
// read endpoints: sites, networks, WLANs, firewall zones, devices, clients โ€ฆ

Base-URL note (verified 2026-05-31 against the .containers/unifi UniFi OS Server container): set BaseUrl to the integration root without /v1 โ€” the client adds /v1/โ€ฆ. UniFi OS exposes it under /proxy/network/integration; a standalone Network Application omits that prefix (/integration).

Packages

Published to nuget.org (public) under the Chrison.* prefix, via Trusted Publishing (OIDC โ€” no stored API key): Chrison.UnifiSharp, Chrison.UnifiSharp.Api, Chrison.UnifiSharp.Cli. Prerelease on push to main (โ€ฆ-preview.N), stable on a v* tag. .Api tracks the UniFi API release; the library its own SemVer. IDs use the Chrison.* prefix because the bare UnifiSharp ID is taken on nuget.org by an unrelated project; assembly names and namespaces stay UnifiSharp, so using UnifiSharp; is unchanged.

Refresh the spec (new UniFi release)

Pull the OpenAPI for the controller's version from the console (Settings โ†’ Integrations) or the beezly/unifi-apis mirror into src/UnifiSharp.Api/schema/, update the filename + VersionPrefix, rebuild.

CLI (unifisharp)

A dotnet global tool over the library:

export UNIFI_BASE_URL="https://localhost:8443/proxy/network/integration/v1"
export UNIFI_API_KEY="โ€ฆ"  UNIFI_VERIFY_TLS=false
unifisharp sites       # list sites
unifisharp discover    # JSON snapshot: sites + networks/WLANs/firewall/devices/clients
unifisharp networks    # networks/VLANs per site (name, vlan id, purpose, enabled)
unifisharp wlans       # WLANs/SSIDs per site (ssid, enabled, security)
unifisharp firewall    # firewall zones, policies, and ACL rules per site
unifisharp devices     # adopted devices per site (name, model, ip, mac, firmware, state)
unifisharp clients     # connected clients per site (name, type, ip, connectedAt)

Status

Read client + discover + unifisharp CLI building from the 10.4.57 spec. Live read tests skip without UNIFI_* โ€” run them against the .containers/unifi test controller (never the live network). Next: the legacy write adapter (firewall rules / port profiles) once verified against the container.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1-preview.4 32 7/24/2026
0.1.0-preview.3 36 7/23/2026
0.1.0-preview.2 39 7/23/2026
0.1.0-preview.1 34 7/23/2026