Files
binarylane-dotnet/README.md
T
2026-08-16 21:52:42 +10:00

3.8 KiB

BinaryLane.Api

CI NuGet

BinaryLane.Api is an unofficial .NET client for the BinaryLane v2 API. It provides typed clients for account, billing, servers, images, DNS, load balancers, VPCs, and other v2 resources.

See the BinaryLane API reference for provider-specific API behaviour.

BinaryLane describes its API as a developer preview. Pin the package version used by production applications and review release notes before upgrading.

This project is not affiliated with, endorsed by, or supported by BinaryLane. For account or infrastructure support, use BinaryLane Support.

Install

dotnet add package BinaryLane.Api --prerelease

Remove --prerelease once a stable package version is available.

Quick start

Keep the API token in a secret store, user secrets, or an environment variable. Do not commit it to configuration or source control.

using BinaryLane.Api.V2;
using BinaryLane.Api.V2.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddBinaryLaneApi(options =>
{
    options.ApiToken = builder.Configuration["BinaryLane:ApiToken"]
        ?? Environment.GetEnvironmentVariable("BINARYLANE_API_TOKEN")
        ?? throw new InvalidOperationException("A BinaryLane API token is required.");
});

var app = builder.Build();

app.MapGet("/account", async (IBinaryLaneClient binaryLane, CancellationToken cancellationToken) =>
    await binaryLane.Account.GetAsync(cancellationToken));

app.Run();

Use the resource clients from IBinaryLaneClient:

static async Task ListServersAsync(
    IBinaryLaneClient binaryLane,
    CancellationToken cancellationToken)
{
    await foreach (var server in binaryLane.Servers.ListAllAsync(cancellationToken: cancellationToken))
    {
        Console.WriteLine($"{server.Id}: {server.Name}");
    }
}

List methods support CancellationToken. Mutating calls are sent once; add a retry policy only when the operation is known to be safe to repeat.

Documentation

Guide Use it for
Getting started Your first request and user-secrets setup.
Configuration Tokens, timeouts, direct construction, and HTTP configuration.
Pagination Working with pages or async enumeration.
Actions Submitting and optionally waiting for server actions.
Error handling Handling API failures safely.
Demo Running the included read-only console app.

Compatibility

The package targets net8.0 and netstandard2.0; .NET 10 applications use the net8.0 asset. Package versions follow Semantic Versioning.

Contributing and security

See CONTRIBUTING.md for development guidance and SECURITY.md for private vulnerability reporting.

License

Distributed under the MIT License.