Safe retries
Exponential backoff for transient failures, idempotent methods only, and Retry-After respected.
GET /orders
503
wait 1 s
backoff
GET /orders
429
Retry-After: 2
honored
GET /orders
200
A small HTTP client inspired by Rust's reqwest. Build a client once, chain the request, finish with Send(). Retries, caching, streaming and auth are already in the box.
.NET 9 · MIT · Native AOT · Cross-platform
Why Nexar
Exponential backoff for transient failures, idempotent methods only, and Retry-After respected.
GET /orders
503
wait 1 s
backoff
GET /orders
429
Retry-After: 2
honored
GET /orders
200
RFC 9111 private cache with ETag revalidation, Vary support and stale-while-revalidate.
MISS
GET /catalog → 200, stored (max-age=60)
HIT
served from memory, no network
REVALIDATED
If-None-Match "a1f3" → 304
SSE, newline-delimited JSON, streamed arrays and Link-header pagination with IAsyncEnumerable.
Bearer, Basic, API keys, Digest and OAuth2 client credentials, client-wide or per request.
IsAotCompatible, with source-generated JSON overloads for every reflection-based member.
$ dotnet publish -p:PublishAot=true
✓ native binary, 0 trim warnings
ActivitySource and Meter following OpenTelemetry HTTP conventions. Secrets are always redacted.
A fluent MockHttp handler matches on method, path, query, headers and body, then verifies calls.
Named and typed clients on IHttpClientFactory, compatible with any IHttpClientBuilder extension.
Examples
A few of the things Nexar handles. The full guide lives in the README.
using Nexar;
var client = NexarClient.Builder()
.BaseUrl("https://api.example.com")
.Timeout(TimeSpan.FromSeconds(30))
.DefaultHeader("Accept", "application/json")
.UserAgent("my-app/1.0")
.Build();
var report = await client.Get("/report")
.Send()
.ErrorForStatus()
.Json<Report>();Install
The fluent HTTP client.
dotnet add package BuzzSpire.NexarIHttpClientFactory integration.
dotnet add package BuzzSpire.Nexar.Extensions.DependencyInjectionFluent mock handler for tests.
dotnet add package BuzzSpire.Nexar.TestingFAQ
Nexar is a small, fluent HTTP client for .NET 9, inspired by Rust's reqwest. You build a NexarClient once, describe each request through method chaining and finish it with Send(). It is open source under the MIT license and maintained by BuzzSpire.
Run dotnet add package BuzzSpire.Nexar. Two optional companion packages exist: BuzzSpire.Nexar.Extensions.DependencyInjection for IHttpClientFactory integration and BuzzSpire.Nexar.Testing for a fluent mock handler.
Nexar runs on the same .NET HTTP stack, but adds what you would otherwise write around HttpClient yourself: fluent request building, retries with backoff and Retry-After, an RFC 9111 HTTP cache, SSE / NDJSON streaming and Link-header pagination, authentication helpers, and OpenTelemetry tracing and metrics.
Yes, when you enable it with Retry(). Connection errors, timeouts and 408, 429, 500, 502, 503 and 504 responses are retried for idempotent methods, with exponential backoff, and a Retry-After header from the server replaces the computed delay.
Yes. The library is marked IsAotCompatible, and every reflection-based JSON member has a source-generated counterpart that takes a JsonTypeInfo, so trimmed and Native AOT apps build without warnings.
Yes. AddNexarClient registers named and typed clients on top of IHttpClientFactory, and MockHttp from BuzzSpire.Nexar.Testing lets you stub routes and verify calls without a network.
Open source under the MIT license.
dotnet add package BuzzSpire.Nexar