Files
binarylane-dotnet/README.md
T
2026-08-17 00:37:53 +10:00

3.7 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. SDK releases track the committed upstream contract independently of the provider's reference version.

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

Quick start

The registration below reads BinaryLane:ApiToken from application configuration and otherwise uses BINARYLANE_API_TOKEN.

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}");
    }
}

All asynchronous resource methods accept a CancellationToken.

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 HTTP exceptions and diagnostic information.
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.