![]() |
VOOZH | about |
dotnet add package ControlR.ApiClient --version 0.17.17
NuGet\Install-Package ControlR.ApiClient -Version 0.17.17
<PackageReference Include="ControlR.ApiClient" Version="0.17.17" />
<PackageVersion Include="ControlR.ApiClient" Version="0.17.17" />Directory.Packages.props
<PackageReference Include="ControlR.ApiClient" />Project file
paket add ControlR.ApiClient --version 0.17.17
#r "nuget: ControlR.ApiClient, 0.17.17"
#:package ControlR.ApiClient@0.17.17
#addin nuget:?package=ControlR.ApiClient&version=0.17.17Install as a Cake Addin
#tool nuget:?package=ControlR.ApiClient&version=0.17.17Install as a Cake Tool
A .NET client library for interacting with the ControlR API. Built with Kiota, this library provides a strongly-typed interface for making API calls to the backend of a ControlR server.
IHttpClientFactorydotnet add package ControlR.ApiClient
The library supports two usage patterns: dependency injection (recommended for most applications) and a static builder pattern (useful for scripts or simple scenarios).
Configure the client in your Program.cs or startup file:
using ControlR.ApiClient;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddControlrApiClient(options =>
{
options.BaseUrl = new Uri("https://your-controlr-server.com");
options.PersonalAccessToken = "your-personal-access-token";
});
You can also load options from configuration using the overload that accepts IConfiguration:
using ControlR.ApiClient;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddControlrApiClient(
builder.Configuration,
ControlrApiClientOptions.SectionKey);
With the following configuration in appsettings.json:
{
"ControlrApiClient": {
"BaseUrl": "https://your-controlr-server.com",
"PersonalAccessToken": "your-personal-access-token"
}
}
Inject either IControlrApiClientFactory or ControlrApiClient directly into your services:
using ControlR.ApiClient;
public class MyService
{
private readonly IControlrApiClientFactory _clientFactory;
private readonly ILogger<MyService> _logger;
public MyService(IControlrApiClientFactory clientFactory, ILogger<MyService> logger)
{
_clientFactory = clientFactory;
_logger = logger;
}
public async Task GetDevicesAsync(CancellationToken cancellationToken)
{
var client = _clientFactory.GetClient();
var devices = await client.Api.Devices.GetAsync(cancellationToken: cancellationToken);
if (devices is null)
{
_logger.LogError("Response was empty.");
return;
}
_logger.LogInformation("Retrieved {DeviceCount} devices.", devices.Count);
foreach (var device in devices)
{
_logger.LogInformation(" - {DeviceName} (ID: {DeviceId})", device.Name, device.Id);
}
}
}
The static builder pattern is useful for console applications, scripts, or scenarios where you prefer not to use dependency injection.
Initialize the builder once at application startup:
using ControlR.ApiClient;
ControlrApiClientBuilder.Initialize(options =>
{
options.BaseUrl = new Uri("https://your-controlr-server.com");
options.PersonalAccessToken = "your-personal-access-token";
});
Get a client instance whenever needed:
var client = ControlrApiClientBuilder.GetClient();
var devices = await client.Api.Devices.GetAsync(cancellationToken: cancellationToken);
if (devices is null)
{
Console.WriteLine("Response was empty.");
return;
}
Console.WriteLine($"Retrieved {devices.Count} devices.");
foreach (var device in devices)
{
Console.WriteLine($" - {device.Name} (ID: {device.Id})");
}
| Property | Type | Required | Description |
|---|---|---|---|
BaseUrl |
Uri |
Yes | The base URL of your ControlR server |
PersonalAccessToken |
string |
Yes | Your personal access token for authentication |
The ControlR API Client uses IHttpClientFactory under the hood to manage HttpClient instances. This provides several benefits:
This means you can safely create multiple client instances without worrying about common pitfalls associated with direct HttpClient usage.
The client is generated using Microsoft's Kiota tool, which provides:
For a complete working example, see the project in this repository.
This project is licensed under the .
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 2 NuGet packages that depend on ControlR.ApiClient:
| Package | Downloads |
|---|---|
|
ControlR.Libraries.Viewer.Common
Common viewer utilities for ControlR, an open-source remote control and remote access solution. |
|
|
ControlR.Viewer.Avalonia
Open-source remote control and remote access. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.25.15 | 44 | 6/27/2026 |
| 0.25.0-dev | 115 | 6/19/2026 |
| 0.24.16 | 119 | 6/18/2026 |
| 0.24.14 | 120 | 6/16/2026 |
| 0.23.17 | 1,462 | 6/2/2026 |
| 0.22.79 | 3,666 | 5/4/2026 |
| 0.21.59 | 982 | 4/7/2026 |
| 0.20.88 | 149 | 3/12/2026 |
| 0.20.87 | 148 | 3/12/2026 |
| 0.20.86 | 124 | 3/5/2026 |
| 0.20.85 | 124 | 3/4/2026 |
| 0.20.84-dev | 118 | 3/4/2026 |
| 0.20.82-dev | 120 | 3/4/2026 |
| 0.20.79-dev | 107 | 3/3/2026 |
| 0.19.2 | 418 | 1/27/2026 |
| 0.18.22 | 171 | 1/12/2026 |
| 0.17.20 | 164 | 12/31/2025 |
| 0.17.19-dev | 130 | 12/31/2025 |
| 0.17.17 | 146 | 12/31/2025 |