Torque.Http 0.5.0

dotnet add package Torque.Http --version 0.5.0
                    
NuGet\Install-Package Torque.Http -Version 0.5.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="Torque.Http" Version="0.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Torque.Http" Version="0.5.0" />
                    
Directory.Packages.props
<PackageReference Include="Torque.Http" />
                    
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 Torque.Http --version 0.5.0
                    
#r "nuget: Torque.Http, 0.5.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 Torque.Http@0.5.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=Torque.Http&version=0.5.0
                    
Install as a Cake Addin
#tool nuget:?package=Torque.Http&version=0.5.0
                    
Install as a Cake Tool

Torque.Http

Official .NET client for Torque — Truespar's in-memory search engine with a Typesense v30.1 compatible API.

  • Zero external NuGet dependencies — built on System.Net.Http and System.Text.Json
  • Source-generated JSON for allocation-free serialization
  • HTTP API for search, collection management, and document CRUD
  • TCP binary ingest (TorqueIngestClient) for high-throughput streaming from databases
  • TQBF file upload (TorqueBinaryWriter) for bulk import
  • Multi-node failover with automatic retry
  • .NET 10+, MIT licensed

Installation

dotnet add package Torque.Http

Quick Start

using Torque.Http;
using Torque.Http.Models;
using Torque.Http.Search;

var client = new TorqueHttpClient(new TorqueHttpClientOptions
{
    ApiKey = "your-key",
    BaseUrl = "http://localhost:8108",
});

var result = await client.SearchAsync(
    "products",
    new SearchBuilder()
        .Query("laptop")
        .QueryBy("title")
        .FilterBy("price:>100")
        .Page(1, 20));

foreach (var hit in result.Hits)
{
    Console.WriteLine(hit.Document["title"]);
}

Typed search with generic result

public record Product(string Id, string Title, double Price, string Brand);

var result = await client.SearchAsync<Product>(
    "products",
    new SearchParameters { Q = "laptop", QueryBy = "title" });

foreach (var hit in result.Hits)
{
    Console.WriteLine($"{hit.Document.Title} — ${hit.Document.Price}");
}

Multi-node with failover

var client = new TorqueHttpClient(new TorqueHttpClientOptions
{
    ApiKey = "your-key",
    Nodes =
    [
        new Uri("https://node1.example.com:8108"),
        new Uri("https://node2.example.com:8108"),
    ],
    MaxRetries = 3,
    RetryBackoff = TimeSpan.FromMilliseconds(100),
});

Collection management

var schema = new CollectionSchema
{
    Name = "products",
    Fields =
    [
        new() { Name = "title", Type = TorqueFieldType.String },
        new() { Name = "price", Type = TorqueFieldType.Float, Sort = true },
        new() { Name = "brand", Type = TorqueFieldType.String, Facet = true },
    ],
};
await client.Collections.CreateAsync(schema);

await client.Documents.CreateAsync("products", new Dictionary<string, object?>
{
    ["id"] = "1",
    ["title"] = "Laptop Pro",
    ["price"] = 1299.99,
    ["brand"] = "Acme",
});

High-throughput TCP ingest

Documents are built via TorqueDocumentBuilder to give you typed field values that round-trip byte-perfect with the server.

using Torque.Http.Tcp;
using Torque.Http.Models;

var docs = new List<TorqueDocument>
{
    new TorqueDocumentBuilder()
        .SetId("1")
        .Set("title", "Laptop Pro")
        .Set("price", 1299.99)
        .Set("brand", "Acme")
        .Build(schema),
    // ...
};

await using var ingest = new TorqueIngestClient(new TorqueIngestOptions
{
    Host = "localhost",
    Port = 8109,
});
await ingest.ConnectAsync();
await ingest.StartIngestAsync("products");
await ingest.SendBatchAsync(docs, schema);
await ingest.CommitAsync();

TQBF bulk file upload

Pre-encode a compressed binary file, then upload via HTTP. The writer handles the upload itself using an injected HttpClient:

using Torque.Http.Tcp;

await using var writer = new TorqueBinaryWriter(schema, "data.tqbf");
foreach (var doc in docs)
    writer.Write(doc);
await writer.FinalizeAsync();

using var http = new HttpClient { BaseAddress = new Uri("http://localhost:8108") };
var result = await writer.UploadAsync(http, "products", "your-key");
Console.WriteLine($"Imported {result.NumImported} documents");

Documentation

License

MIT.

Product 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

    • 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.5.0 104 4/11/2026