Your first .NET client
Create a console app that pairs with Core and reads Host identity.
AlphaThis console application uses only public Client/Contracts libraries. It requests host.status, waits for user approval and prints the connected Host identity. It works even when Core has no open project.
Add the client library
Create the app outside the Streaming Hub checkout:
dotnet new console --framework net8.0 --name MyStreamingHubClient
cd MyStreamingHubClient
Obtain matching Client/Contracts .nupkg files from the API Client archive of the preview package you are evaluating. Extract them into a local package directory. Replace both placeholders with that package set's exact values:
$packageVersion = 'REPLACE_WITH_EXACT_PACKAGE_VERSION'
$packageDirectory = 'C:\StreamingHubApiPackages'
dotnet add package StreamingHub.Api.Client --version $packageVersion --source $packageDirectory
This does not imply publication on a public feed. When developing against this repository instead, add a project reference to StreamingHub.Api.Client/StreamingHub.Api.Client.csproj; Contracts is its dependency. Do not reference CoreHost or Editor.
Replace Program.cs
using StreamingHub.Api.Client;
using StreamingHub.Api.Contracts;
using var deadline = new CancellationTokenSource(TimeSpan.FromSeconds(110));
Console.CancelKeyPress += (_, e) => {
e.Cancel = true;
deadline.Cancel();
};
var token = deadline.Token;
const string clientId = "example.my-streaminghub-client";
string[] scopes = ["host.status"];
try
{
var discovery = await ApiHostDiscovery.ReadAsync(
args.Length > 0 ? args[0] : null, token);
using var client = new StreamingHubApiClient(discovery);
var request = await client.RequestPairingAsync(
new PairingRequestDto(clientId, "My Streaming Hub client",
"Local example (claimed)", scopes), token);
Console.WriteLine("Approve My Streaming Hub client in the Core tray.");
PairingResult result;
do
{
result = await client.PollPairingAsync(request, token);
if (result.Status == "pending")
await Task.Delay(500, token);
} while (result.Status == "pending");
if (result.Credential is not { } credential)
{
Console.WriteLine($"Pairing ended: {result.Status}");
return;
}
await client.ConnectWithCredentialAsync(
clientId, credential.Secret, scopes, token);
var host = await client.GetHostAsync(token);
Console.WriteLine($"Connected to Core {host.HostInstanceId}");
}
catch (ApiClientException error)
{
Console.Error.WriteLine(error.Code);
}
catch (OperationCanceledException)
{
Console.Error.WriteLine("Cancelled or timed out.");
}
catch (HttpRequestException)
{
Console.Error.WriteLine("Core could not be reached. Check discovery and Core status.");
}
The example keeps the credential in memory for this run. A returning application should store it in protected local storage, reuse its stable client ID and reconnect with the same credential. A new pairing creates a new principal with a separate command recovery context.
Run
With Core and Tray running:
dotnet run
For a custom data directory:
dotnet run -- C:\StreamingHubApiTest\api-discovery.json
Approve only host.status in Tray. The console prints Host identity. Denial, timeout and incompatibility produce an explicit result.
Extend your application
Request project.read too, obtain approval for those rights, then call GetCompleteSnapshotAsync(ct: token) once a project is open. Use the returned identity and revision when building a change. Renewal cannot add scopes to an existing grant.
Keep network work cancellable and observe Core without blocking your interface. The repository example adds open, switch, rename, run and Save.