ThreeXui.Net 1.0.4

dotnet add package ThreeXui.Net --version 1.0.4
                    
NuGet\Install-Package ThreeXui.Net -Version 1.0.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="ThreeXui.Net" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ThreeXui.Net" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="ThreeXui.Net" />
                    
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 ThreeXui.Net --version 1.0.4
                    
#r "nuget: ThreeXui.Net, 1.0.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 ThreeXui.Net@1.0.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=ThreeXui.Net&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=ThreeXui.Net&version=1.0.4
                    
Install as a Cake Tool

ThreeXui.Net

Build Tests NuGet Downloads License: MIT

A standalone, reusable .NET client for the 3x-ui / x-ui panel REST API. Multi-targets netstandard2.0 (max reach: .NET Framework 4.6.1+, Mono, Unity) and net10.0 (in-box BCL, no polyfills).

What it does

  • Cookie-session auth with lazy login and automatic re-auth on an expired session (401, 403, or a 301/302/307/308 redirect back to /login), deduplicated under a login gate so concurrent calls never burn duplicate logins.
  • Inbound listing (/panel/api/inbounds/list) and single-inbound fetch.
  • Per-client traffic (GetInboundClientTrafficAsync) from the list endpoint — not the single-inbound one, which some 3x-ui versions (confirmed on v2.8.11) don't preload clientStats on.
  • Per-client CRUD (add / update / remove) via a Get → mutate settings.clients[] → Update inbound fallback, which works on forks without reliable addClient / delClient endpoints (notably x-ui v2.4.11). Serialized by a per-inbound mutex.
  • Health probing with classified error messages (TLS handshake, unreachable host, HTML-instead-of-API, auth failure, server 5xx).
  • Connection-string builders for vless, vmess, trojan, shadowsocks, including streamSettings transport/security rendering (tcp, mKCP, WebSocket, gRPC, HTTPUpgrade, XHTTP — all six 3x-ui transports) and externalProxy (CDN/front) endpoints. XuiConnectionStringRequest.ForcedFingerprint/ForcedPacketEncoding let the caller override/add link params (fp, packetEncoding) that 3x-ui itself doesn't set but real client apps need.

Install

dotnet add package ThreeXui.Net

Dependency injection

The simplest way to wire the client into an IServiceCollection (ASP.NET Core, generic host, worker service):

using ThreeXui;
using ThreeXui.DependencyInjection;

builder.Services.AddXuiClient(options =>
{
    options.BaseAddress = new Uri("https://panel.example.com:2053/");
    options.Username = "admin";
    options.Password = "secret";
    options.AllowInsecureTls = false;            // true for self-signed panels
    // options.Timeout = TimeSpan.FromSeconds(30);
});

Then just inject IXuiClient:

public sealed class PanelService(IXuiClient client)
{
    public Task<XuiHealthCheckResult> PingAsync(CancellationToken ct) =>
        client.CheckHealthAsync(ct);
}

AddXuiClient registers IXuiClient as a singleton — one instance keeps the cookie session and per-inbound mutexes that serialize concurrent client mutations. The HttpClient is built once from the registered IXuiHttpClientFactory (a default is added unless you registered your own), and an ILogger<XuiClient> is picked up automatically when logging is configured.

Quick start

using ThreeXui;
using ThreeXui.Http;

var httpFactory = new XuiHttpClientFactory();
var http = httpFactory.Create(
    baseAddress: new Uri("https://panel.example.com:2053/"),
    allowInsecureTls: false);

using IXuiClient client = new XuiClient(http, username: "admin", password: "secret");

// Health
var health = await client.CheckHealthAsync(ct);

// List inbounds
var inbounds = await client.ListInboundsAsync(ct);

// Add a client to an inbound
var result = await client.AddClientAsync(
    inboundExternalId: "1",
    new AddClientRequest(
        Name: "alice",
        Email: "alice-ab12cd34",
        Protocol: "vless",
        LimitIp: 0,
        ExpiresAt: DateTimeOffset.UtcNow.AddDays(30)),
    ct);

// Build a share link
using ThreeXui.ConnectionStrings;

var resolver = new XuiConnectionStringBuilderResolver();
var inbound = await client.GetInboundAsync("1", ct);
var link = resolver.Resolve("vless")!.Build(new XuiConnectionStringRequest(
    ExternalClientId: result.ExternalClientId,
    Name: "alice",
    InboundPort: inbound!.Port,
    PublicHost: null,
    BaseUrl: "https://panel.example.com:2053/",
    Inbound: inbound));

Notes

  • XuiClient takes an already-built HttpClient and owns it for its lifetime — it implements IDisposable, so Dispose() (or the DI container at shutdown) disposes the HttpClient and the internal locks. Use XuiHttpClientFactory (cookie container + no auto-redirect + optional self-signed TLS opt-in), or supply your own.
  • AddXuiClient enforces the base-URL policy: HTTPS is always allowed, plain HTTP only for private/loopback/*.local hosts. A public http:// panel is rejected. Use XuiBaseUrlValidator directly to check a URL yourself.
  • Multiple 3x-ui / x-ui versions are supported: cross-version behaviour (e.g. GetServerInfoAsync, health probing) degrades gracefully from the newest /panel/api/server/status shape down to old forks (x-ui v2.4.11) that expose only /panel/api/inbounds.
  • AllowInsecureTls on the netstandard2.0 target requires .NET Framework 4.7.1+ (self-signed cert skipping is a no-op-throwing API on 4.6.1–4.7.0); on net10.0 / modern .NET it always works.
  • Logging is optional and uses Microsoft.Extensions.Logging.Abstractions — pass an ILogger<XuiClient> or nothing.
  • Secret storage, credential decryption, caching and metrics are intentionally out of scope: the library does the protocol, the host application owns persistence.

License

MIT — see LICENSE.

Product 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
.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. 
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
1.0.4 46 7/23/2026
1.0.3 47 7/22/2026
1.0.2 46 7/22/2026
1.0.1 158 7/2/2026
1.0.0 124 7/1/2026
0.1.4 99 7/1/2026
0.1.3 98 7/1/2026
0.1.2 104 7/1/2026
0.1.1 97 7/1/2026