UniFiSharp 1.4.0
See the version list below for details.
dotnet add package UniFiSharp --version 1.4.0
NuGet\Install-Package UniFiSharp -Version 1.4.0
<PackageReference Include="UniFiSharp" Version="1.4.0" />
paket add UniFiSharp --version 1.4.0
#r "nuget: UniFiSharp, 1.4.0"
// Install UniFiSharp as a Cake Addin #addin nuget:?package=UniFiSharp&version=1.4.0 // Install UniFiSharp as a Cake Tool #tool nuget:?package=UniFiSharp&version=1.4.0
UniFiSharp
Bringing Ubiquiti UniFi Orchestration Automation to C#
UniFiSharp provides a basic C# API for Ubiquiti UniFi controllers, as well as an orchestration overlay to more easily visualize network topology and execute device commands. UniFiSharp also implements both v1 and v2 of the Ubiquiti discovery protocol for automated controller discovery.
As of UniFiSharp v1.1.0, the API surface has changed slightly to improve usability and maintainability; please read the usage documentation below.
This project is written for any .NET application that can consume a .NET Standard 2.0 library. All future contributions are planned to continue to enable cross-platform use.
Basic API Usage
The UniFiApi
class provides all base-level API features:
// Instantiate the API object
using (var api = new UniFiSharp.UniFiApi(new Uri("https://controller:8443"), "username", "password", "siteName"))
{
// Manually calling .Authenticate() forces the API to proactively authenticate.
// Otherwise, the request will be automatically authenticated upon receiving an unauthorized error.
await api.Authenticate();
// ... for example, enumerate all UniFi devices known by the controller:
IEnumerable<UniFiSharp.Json.JsonNetworkDevice> uniFiDevices = await api.NetworkDeviceList();
// ... or to upgrade the firmware on a device:
await api.NetworkDeviceUpgrade("01:23:45:67:89:AB");
}
UBNT Cloud
The UniFiApi
class can also be used with UBNT Cloud-hosted services by changing the base URI to match the UBNT Cloud format:
var api = new UniFiSharp.UniFiApi(new Uri("https://demo.ubnt.com/"), "username", "password")
Note: At the time of this writing, Ubiquiti's cloud will accept the above demo credentials and allow the user to work in a sandboxed, artificial environment. This demo setup includes approximately 130 UniFi devices and 1200 clients.
Orchestration Usage
In order to make this system more developer-friendly, it also ships with an orchestration overlay that wraps the UniFiApi
object and associates common information to their devices, as well as attempting to converge a basic topology based on the device objects:
// Instantiate the API object
using (var api = new UniFiSharp.UniFiApi(new Uri("https://controller:8443"), "username", "password", "siteName"))
using (var orchestrator = new UniFiSharp.Orchestration.UniFiOrchestrator(api))
{
// Calls api.Refresh() under the hood
await orchestrator.Refresh();
// ... for example, retrieve the first AP and turn on its locator for 5 seconds:
await orchestrator.InfrastructureDevices.First(d => d is UniFiSharp.Orchestration.Devices.AccessPointInfrastructureNetworkedDevice).Locate(5000);
// ... or to browse the network topology from the edge inwards, start from:
INetworkedDevice networkRoot = orchestrator.TopologicalRoot;
// ... or to create a new port forward (to 192.168.1.100:TCP/80):
await orchestrator.PortForwards.Add(
UniFiSharp.Orchestration.Models.PortForward.Create(
name: "abc",
proto: "tcp",
source: "any",
sourcePort: 80,
dest: "192.168.1.100",
destPort: 80
));
}
Disclaimer
This software is not affiliated with nor supported by Ubiquiti Networks and is offered under the license as described in LICENSE
. This software should never be used in a production environment without exhaustive, independent testing.
The "U" logo component used is strictly for product identification purposes only, and is protected by fair use.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.1)
- RestSharp (>= 106.12.0)
- RestSharp.Serializers.NewtonsoftJson (>= 106.12.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.