TrashDB.Client 0.1.0

dotnet add package TrashDB.Client --version 0.1.0
                    
NuGet\Install-Package TrashDB.Client -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TrashDB.Client" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TrashDB.Client" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="TrashDB.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TrashDB.Client --version 0.1.0
                    
#r "nuget: TrashDB.Client, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TrashDB.Client@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TrashDB.Client&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=TrashDB.Client&version=0.1.0
                    
Install as a Cake Tool

TrashDB .NET SDK

NuGet CI License: MIT

Official C# / .NET client for TrashDB — spin up an ephemeral database in seconds, destroy it when you're done.

using var client = new TrashDBClient(new TrashDBOptions { ApiKey = "your-api-key" });

var container = await client.CreateContainerAsync(new CreateContainerParams
{
    Engine     = "postgres",
    TtlMinutes = 10,
    Name       = "my-integration-test-db",
});

Console.WriteLine(container.ConnectionString);
// Host=localhost;Port=54321;Database=trashdb;Username=trashdb;Password=...

await client.DestroyContainerAsync(container.Id);

Why TrashDB?

  • Zero infra overhead — no Docker Compose files, no local DBs to manage, no cleanup scripts.
  • Every test gets a fresh database — no shared state, no flaky tests from leftover data.
  • 6 engines, one API — PostgreSQL, Redis, MongoDB, Qdrant, ChromaDB, Supabase.
  • Auto-expiry — containers self-destruct after your TTL. Forget about it.
  • CI-native — one API call to get a real database in your pipeline.

Installation

dotnet add package TrashDB.Client

Targets: netstandard2.1, net6.0, net8.0. Zero runtime dependencies.


Quick Start

1. Get an API key

Sign up at trashdb.dev and grab your API key from the dashboard.

2. Configure

Set the TRASHDB_API_KEY environment variable, or pass it directly:

export TRASHDB_API_KEY="trashdb-your-key-here"

3. Use the client

using TrashDB.Client;
using TrashDB.Client.Models;

// Option A: reads TRASHDB_API_KEY from environment
using var client = new TrashDBClient();

// Option B: explicit
using var client = new TrashDBClient(new TrashDBOptions
{
    ApiKey  = "trashdb-your-key-here",
    BaseUrl = "https://api.trashdb.dev/api/v1", // optional, this is the default
});

API Reference

CreateContainerAsync

Provisions a new ephemeral database container.

var container = await client.CreateContainerAsync(new CreateContainerParams
{
    Engine     = "postgres",   // required — see supported engines below
    TtlMinutes = 15,           // 1–1440 (24h). Defaults to 5.
    Name       = "my-db",      // optional friendly name
});

// container.Id              — unique container ID
// container.Engine          — "postgres"
// container.Port            — host port (e.g. 54321)
// container.ConnectionString — ready-to-use connection string
// container.ExpiresAt       — when the container will be destroyed

GetRunningContainersAsync

Lists all containers currently running for your account.

var containers = await client.GetRunningContainersAsync();
foreach (var c in containers)
    Console.WriteLine($"{c.Engine} on port {c.Port} — expires {c.ExpiresAt:u}");

DestroyContainerAsync

Destroys a container immediately, regardless of its TTL.

bool ok = await client.DestroyContainerAsync(container.Id);

GetEnginesAsync

Returns the list of supported database engines.

var engines = await client.GetEnginesAsync();
// [{ Id="postgres", Name="PostgreSQL", MaxTtlMinutes=1440 }, ...]

GetContainerLogsAsync

Retrieves recent log output from a running container (useful for debugging).

string logs = await client.GetContainerLogsAsync(
    containerId:   container.Id,
    tail:          100,          // last N lines, default 200
    sinceSeconds:  300           // last 5 minutes, optional
);

Supported Engines

Engine ID Description
postgres PostgreSQL 16
redis Redis 7
mongodb MongoDB 7
chromadb ChromaDB (vector database)
qdrant Qdrant (vector database)
supabase Supabase-compatible PostgreSQL

Connection Strings

Each engine returns a ready-to-use connection string in container.ConnectionString:

Engine Format
postgres Host=localhost;Port=54321;Database=trashdb;Username=trashdb;Password=...
redis redis://:password@localhost:6379
mongodb mongodb://trashdb:password@localhost:27017/trashdb
chromadb http://localhost:8000
qdrant http://localhost:6333
supabase Same as postgres

Error Handling

All API errors throw TrashDBApiException:

using TrashDB.Client.Exceptions;
using TrashDB.Client.Models;

try
{
    var container = await client.CreateContainerAsync(new CreateContainerParams
    {
        Engine = "postgres",
        TtlMinutes = 9999, // exceeds limit
    });
}
catch (TrashDBApiException ex)
{
    Console.WriteLine($"HTTP {ex.HttpStatus}, code {ex.Code}: {ex.Message}");
    // HTTP 400, code 1003: TTL exceeds the maximum allowed value.

    if (ex.Code == TrashDBErrorCode.QuotaExceeded)
        Console.WriteLine("You've hit your monthly quota.");
}

Error codes

Code Constant Meaning
1001 EngineNotSupported Unknown engine identifier
1003 TtlExceedsLimit TTL above engine maximum
1004 ContainerNotFound Container ID does not exist
1005 QuotaExceeded Monthly container quota reached
1006 SimultaneousLimitReached Too many containers at once
4001 Unauthorized Invalid or missing API key

Full list in TrashDBErrorCode.


Advanced Usage

Dependency Injection (ASP.NET Core)

// Program.cs
builder.Services.AddSingleton(_ => new TrashDBClient(new TrashDBOptions
{
    ApiKey = builder.Configuration["TrashDB:ApiKey"],
}));

Testing with a mock HttpClient

var handler = new MockHttpMessageHandler();
var http    = new HttpClient(handler) { BaseAddress = new Uri("http://localhost") };

using var client = new TrashDBClient(new TrashDBOptions
{
    ApiKey     = "test-key",
    BaseUrl    = "http://localhost/api/v1",
    HttpClient = http,
});

Custom base URL (self-hosted)

using var client = new TrashDBClient(new TrashDBOptions
{
    ApiKey  = "your-key",
    BaseUrl = "https://your-trashdb-instance.example.com/api/v1",
});

Retry configuration

By default, the client retries 3 times on 502 / 503 / 504 with exponential backoff starting at 500 ms.

using var client = new TrashDBClient(new TrashDBOptions
{
    ApiKey         = "your-key",
    MaxRetries     = 5,
    InitialBackoff = TimeSpan.FromSeconds(1),
});

Use in CI / Integration Tests

A common pattern — create a container at test setup, destroy it at teardown:

// xUnit example
public class MyDbTests : IAsyncLifetime
{
    private TrashDBClient _trashDb = null!;
    private ContainerResponse _container = null!;

    public async Task InitializeAsync()
    {
        _trashDb   = new TrashDBClient();
        _container = await _trashDb.CreateContainerAsync(new CreateContainerParams
        {
            Engine     = "postgres",
            TtlMinutes = 10,
        });
        // Use _container.ConnectionString to configure your DbContext / Npgsql connection
    }

    public async Task DisposeAsync()
    {
        await _trashDb.DestroyContainerAsync(_container.Id);
        _trashDb.Dispose();
    }

    [Fact]
    public async Task MyTest()
    {
        // _container.ConnectionString is ready to use
    }
}

Other SDKs & Integrations

SDK / Tool Install Docs
TypeScript npm install @trashdb/ts npm
Python pip install trashdb PyPI
C# / .NET dotnet add package TrashDB.Client (you are here)
GitHub Action trashdb/run-tests-action@v1 Marketplace
MCP Server npx @trashdb/mcp npm

Contributing

Pull requests are welcome! Please open an issue first for major changes.

git clone https://github.com/trashdb/sdk-dotnet
cd sdk-dotnet
dotnet build
dotnet test

License

MIT © TrashDB

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 270 7/8/2026