.NET HTTP Client
Typed HTTP client for the Traverse management API — manage databases, files, users, and schema from .NET.
dotnet add package Traverse.Http
Targets net10.0. Zero external dependencies.
Connect
using Traverse.Http;
var client = new TraverseHttpClient("http://localhost:7691",
new TraverseHttpOptions { ApiKey = "tvs_your_api_key" });
// Or wrap an existing HttpClient
var client = new TraverseHttpClient(httpClient);
Client Options
| Option | Type | Default | Description |
|---|---|---|---|
ApiKey | string? | null | Bearer token for API authentication |
AllowUntrustedCertificate | bool | false | Skip TLS certificate validation |
Timeout | TimeSpan? | 100 seconds | Default request timeout |
FileTransferTimeout | TimeSpan? | null | Timeout for file upload/download operations |
Health & Status
// Server health (version, memory, database summary)
var health = await client.HealthAsync();
Console.WriteLine(health.Version);
// Readiness check
bool ready = await client.ReadyAsync();
Database Management
// List all databases
var databases = await client.ListDatabasesAsync();
// Create, rename, drop
await client.CreateDatabaseAsync("mydb");
await client.RenameDatabaseAsync("mydb", "production");
await client.DropDatabaseAsync("production");
// Unload from memory (keeps .tvdb file)
await client.UnloadDatabaseAsync("archive");
// Load from a .tvdb file
await client.LoadDatabaseAsync("archive", "archive.tvdb");
Long-running operations like DropDatabaseAsync and UnloadDatabaseAsync accept an IProgress<TaskInfo> to track async task progress.
File Management
Upload, download, and manage .tvdb database files on the server:
// List files
var files = await client.ListFilesAsync();
// Upload a .tvdb file
await using var stream = File.OpenRead("backup.tvdb");
var result = await client.UploadFileAsync("backup.tvdb", stream);
// Download
await using var output = File.Create("download.tvdb");
await client.DownloadFileAsync("backup.tvdb", output);
// Delete
await client.DeleteFileAsync("backup.tvdb");
Upload and download methods accept IProgress<long> for byte-level progress tracking.
Aliases
// List aliases
var aliases = await client.ListAliasesAsync();
// Create, alter, drop
await client.CreateAliasAsync("default", "production");
await client.AlterAliasAsync("default", "staging");
await client.DropAliasAsync("default");
Schema
// Get labels, relationship types, indexes, constraints
var schema = await client.GetSchemaAsync("mydb");
Query Execution
var response = await client.QueryAsync(
"MATCH (n:Person) RETURN n.name LIMIT 10",
parameters: null,
database: "mydb");
Import
// Import Cypher statements
var result = await client.ImportCypherAsync(
"CREATE (a:Person {name:'Alice'})-[:KNOWS]->(b:Person {name:'Bob'})",
database: "mydb");
// Import CSV nodes
var csvResult = await client.ImportCsvAsync(
csvContent,
label: "Person",
columns: new[] {
new CsvColumnMapping("name", "STRING"),
new CsvColumnMapping("age", "INTEGER")
},
database: "mydb",
delimiter: ",",
skipHeader: true);
// Import CSV edges
var edgeResult = await client.ImportCsvEdgesAsync(
csvContent,
edgeType: "KNOWS",
source: new CsvEdgeEndpoint("Person", "name"),
target: new CsvEdgeEndpoint("Person", "name"),
database: "mydb");
User Management
// List users
var users = await client.ListUsersAsync();
// Create, update, delete
await client.CreateUserAsync("alice", "password123", "EDITOR");
await client.UpdateUserAsync("alice", role: "ADMIN");
await client.DeleteUserAsync("alice");
Server Operations
// Persist all databases to disk
await client.SaveAsync();
// Check async task status
var task = await client.GetTaskAsync(taskId);
Error Handling
try
{
await client.DropDatabaseAsync("nonexistent");
}
catch (TraverseHttpException ex)
{
Console.WriteLine(ex.StatusCode); // HttpStatusCode.NotFound
Console.WriteLine(ex.Message);
}