HTTP for .NET,
the fluent way.

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

Nexar.Demo — Program.cs
Program.cs
var client = NexarClient.Builder() .BaseUrl("https://api.example.com") .Retry(maxRetries: 3) .Logger(logger) .Build(); var user = await client.Get("/users/1") .BearerAuth(token) .Send() .ErrorForStatus() .Json<User>();
$ dotnet run

Why Nexar

Everything you wrap around HttpClient. Built in.

Safe retries

Exponential backoff for transient failures, idempotent methods only, and Retry-After respected.

  1. GET /orders

    503

  2. wait 1 s

    backoff

  3. GET /orders

    429

  4. Retry-After: 2

    honored

  5. GET /orders

    200

HTTP caching

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

Streaming built in

SSE, newline-delimited JSON, streamed arrays and Link-header pagination with IAsyncEnumerable.

event: token data: "Hel"
event: token data: "lo, "
event: token data: "Ada"
id: 42 retry: 3000
event: token data: "!"
event: done data: [DONE]
event: token data: "Hel"
event: token data: "lo, "
event: token data: "Ada"
id: 42 retry: 3000
event: token data: "!"
event: done data: [DONE]

Authentication

Bearer, Basic, API keys, Digest and OAuth2 client credentials, client-wide or per request.

BearerBasicAPI keyDigestOAuth2

Native AOT ready

IsAotCompatible, with source-generated JSON overloads for every reflection-based member.

$ dotnet publish -p:PublishAot=true

✓ native binary, 0 trim warnings

Observability

ActivitySource and Meter following OpenTelemetry HTTP conventions. Secrets are always redacted.

Testable

A fluent MockHttp handler matches on method, path, query, headers and body, then verifies calls.

DI friendly

Named and typed clients on IHttpClientFactory, compatible with any IHttpClientBuilder extension.

Examples

Reads like what it does.

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>();
Build one client, reuse it everywhere. Thread-safe and owns its connection pool.

Install

Three packages. Pick what you need.

FAQ

Questions, answered.

What is Nexar?

+

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.

How do I install Nexar?

+

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.

How is Nexar different from using HttpClient directly?

+

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.

Does Nexar retry failed requests?

+

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.

Is Nexar compatible with Native AOT?

+

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.

Can I use Nexar with dependency injection and unit tests?

+

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.

Stop wrapping HttpClient.

Open source under the MIT license.

$dotnet add package BuzzSpire.Nexar