Skip to content

Hylaean/tofupilot-csharp

Repository files navigation

TofuPilot C# SDK

NuGet License: MIT .NET

Unofficial open-source C# SDK for TofuPilot. Integrate all your hardware test runs into one app with just a few lines of C#.

Looking for the official client? See tofupilot/csharp-client.

Installation

dotnet add package Hylaean.TofuPilot

Quick Start

using Hylaean.TofuPilot;
using Hylaean.TofuPilot.Models.Runs;
using Hylaean.TofuPilot.Abstractions.Models;

// Create a client (reads TOFUPILOT_API_KEY from environment by default)
using var client = new TofuPilotClient(apiKey: "your-api-key");

// List recent runs
var runs = await client.Runs.ListAsync(new ListRunsRequest { Limit = 10 });

// Create a test run
var run = await client.Runs.CreateAsync(new CreateRunRequest
{
    ProcedureId = "your-procedure-id",
    Outcome = RunOutcome.PASS,
    SerialNumber = "SN-001",
    StartedAt = DateTimeOffset.UtcNow.AddMinutes(-5),
    EndedAt = DateTimeOffset.UtcNow
});

Console.WriteLine($"Created run: {run.Id}");

Dependency Injection

services.AddTofuPilot(options =>
{
    options.ApiKey = configuration["TofuPilot:ApiKey"];
    options.BaseUrl = "https://www.tofupilot.com";
    options.Retry = new RetryOptions
    {
        MaxRetries = 3,
        InitialDelayMs = 1000,
        MaxDelayMs = 30000
    };
});

// Inject TofuPilotClient anywhere
public class TestRunService(TofuPilotClient client)
{
    public Task<Run> CreateTestRunAsync(string serialNumber) =>
        client.Runs.CreateAsync(new CreateRunRequest
        {
            ProcedureId = "proc-123",
            Outcome = RunOutcome.PASS,
            SerialNumber = serialNumber,
            StartedAt = DateTimeOffset.UtcNow.AddMinutes(-5),
            EndedAt = DateTimeOffset.UtcNow
        });
}

Documentation

Topic Description
Resources Full reference for all API resources (runs, units, procedures, parts, batches, stations, attachments, users)
Configuration Direct instantiation, DI setup, environment variables, retry options
Error Handling Typed exceptions, status codes, base exception properties
API Coverage Operation-by-operation mapping to the OpenAPI spec

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Links

About

C# API client for TofuPilot.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages