NSprites 0.1.4
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package NSprites --version 0.1.4
NuGet\Install-Package NSprites -Version 0.1.4
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="NSprites" Version="0.1.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NSprites" Version="0.1.4" />
<PackageReference Include="NSprites" />
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 NSprites --version 0.1.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NSprites, 0.1.4"
#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 NSprites@0.1.4
#: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=NSprites&version=0.1.4
#tool nuget:?package=NSprites&version=0.1.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NSprites
A .NET client library for the Sprites.dev API.
Features
- Full REST API Support: Create, manage, and delete sprites
- Checkpoint Management: Create and restore filesystem snapshots
- Command Execution: Run commands with streaming output
- Async/Await: Modern async API throughout
- Strongly Typed: Full type safety with records and enums
- Testable: Dependency injection friendly with mocked HTTP clients
Installation
dotnet add package NSprites
Quick Start
using NSprites;
// Create a client with your token
var client = new SpritesClient("your-sprites-token");
// Create a new sprite
var sprite = await client.CreateSpriteAsync(new CreateSpriteRequest("my-sprite"));
Console.WriteLine($"Created sprite: {sprite.Url}");
// Get an existing sprite client
var mySprite = client.Sprite("my-sprite");
// Run a command
var result = await mySprite.Exec.RunCommandAsync(
new ExecuteRequest(new[] { "echo", "Hello, World!" }));
Console.WriteLine(result.Stdout); // "Hello, World!\n"
// Create a checkpoint
await foreach (var @event in mySprite.Checkpoints.CreateAsync("Before deployment"))
{
Console.WriteLine($"Checkpoint: {@event.Data}");
}
// List checkpoints
var checkpoints = await mySprite.Checkpoints.ListAsync();
foreach (var cp in checkpoints)
{
Console.WriteLine($"Checkpoint: {cp.Id} - {cp.Comment}");
}
API Overview
Sprites
// List all sprites
var sprites = await client.ListSpritesAsync();
// Create a sprite
var sprite = await client.CreateSpriteAsync(new CreateSpriteRequest("my-app"));
// Get sprite details
var details = await client.Sprite("my-app").GetAsync();
// Update URL settings
await client.Sprite("my-app").UpdateUrlSettingsAsync("public");
// Delete a sprite
await client.Sprite("my-app").DeleteAsync();
Checkpoints
var checkpoints = client.Sprite("my-app").Checkpoints;
// Create a checkpoint with streaming events
await foreach (var @event in checkpoints.CreateAsync("Backup before deploy"))
{
Console.WriteLine($"{@event.Type}: {@event.Data}");
}
// List checkpoints
var list = await checkpoints.ListAsync();
// Get specific checkpoint
var cp = await checkpoints.GetAsync("v1");
// Restore to a checkpoint
await foreach (var @event in checkpoints.RestoreAsync("v1"))
{
Console.WriteLine($"{@event.Type}: {@event.Data}");
}
Command Execution
var exec = client.Sprite("my-app").Exec;
// Run a simple command
var result = await exec.RunCommandAsync(
new ExecuteRequest(new[] { "python", "-c", "print(42)" }));
Console.WriteLine($"Exit code: {result.ExitCode}");
Console.WriteLine($"Output: {result.Stdout}");
// Run with environment variables
var result = await exec.RunCommandAsync(new ExecuteRequest(
Command: new[] { "env" },
Env: new[] { "MY_VAR=test" },
Dir: "/tmp"
));
// List active sessions
var sessions = await exec.ListSessionsAsync();
// Kill a session
await foreach (var @event in exec.KillSessionAsync(123))
{
Console.WriteLine($"{@event.Type}: {@event.Message}");
}
Error Handling
All API errors are wrapped in SpritesApiException:
try
{
var sprite = await client.Sprite("nonexistent").GetAsync();
}
catch (SpritesApiException ex)
{
Console.WriteLine($"API Error: {ex.ErrorCode} - {ex.Message}");
// ErrorCode: NotFound, StatusCode: 404
}
Available error codes:
Unauthorized- Authentication requiredForbidden- Access deniedNotFound- Resource not foundConflict- Resource conflictValidationError- Invalid request dataRateLimited- Too many requestsInternalServerError- Server error
Testing
The library is designed for easy testing with dependency injection:
// In production
var client = new SpritesClient("token");
// In tests
var mockHttp = new HttpClient(new HttpMessageHandlerMock());
var client = new SpritesClient("token", mockHttp);
See the test files for examples of mocking HTTP responses.
Requirements
- .NET 10.0+
- Sprites.dev account and API token
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.Http (>= 10.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NSprites:
| Package | Downloads |
|---|---|
|
MonumentalSystems.Sprites
A Semantic Kernel plugin for Sprites containerized development environment integration. Provides tools for managing sprites, executing commands, creating checkpoints, and establishing port forwarding tunnels. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.6.0 | 228 | 2/15/2026 |
| 0.5.3-alpha.0.15 | 83 | 2/15/2026 |
| 0.5.0 | 126 | 1/18/2026 |
| 0.4.0 | 128 | 1/18/2026 |
| 0.3.1 | 123 | 1/18/2026 |
| 0.2.2 | 128 | 1/18/2026 |
| 0.2.1 | 123 | 1/18/2026 |
| 0.2.0 | 132 | 1/18/2026 |
| 0.1.9 | 129 | 1/17/2026 |
| 0.1.8 | 125 | 1/17/2026 |
| 0.1.7 | 129 | 1/17/2026 |
| 0.1.6 | 126 | 1/17/2026 |
| 0.1.4 | 127 | 1/17/2026 |