Lyo.Api.Client 1.0.6

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

Lyo.Api.Client

HTTP client for Lyo minimal APIs: JSON in/out, gzip/brotli/deflate, query-string encoding for GET DTOs, file upload helpers, and System.Text.Json parity with server options when you wire them.

ApiClient implements IDisposable and disposes its resources. Resolve it via IHttpClientFactory so lifetimes stay correct in DI.

Examples

DI registration

services.AddLyoApiClient(
    optionsOverride: o => {
        o.BaseUrl = "https://api.example.com/";
        o.EnableAutoResponseDecompression = true;
        o.AcceptEncodings = ["gzip", "br"];
        o.RequestCompression = ApiRequestCompressionType.Gzip;
        o.RequestCompressionMinBytes = 4 * 1024;
    },
    httpClientBuilderOverride: b => b.AddStandardResilienceHandler());

IApiClient methods

Serialization

  • GetSerializerOptions() exposes effective JsonSerializerOptions. Use the same instance for ad-hoc serializers in your worker to avoid schema drift.

GET

  • GetAsAsync<TResult>(uri, beforeRequest, ct) returns deserialized JSON.
  • GetAsAsync<TRequest, TResult>(uri, query, enumerableDelimiter, …) serializes TRequest properties as query parameters so GET DTOs match Lyo.Api flattened query endpoints.

Bodies and verbs

  • PostAsAsync / PutAsAsync / PatchAsAsync / DeleteAsAsync map to JSON content (generic + non-generic overloads).
  • PostAsBinaryAsync for raw byte returns (exports, generated PDFs, etc.).

Files

  • GetFileAsync / GetFileWithTypeAsync buffer entire payload.
  • GetFileStreamAsync returns Stream + filename + length without forcing memory spikes. The caller disposes underlying HttpResponseMessage per XML contract.
  • PostFileAsAsync overloads stream/byte[]/path + FileTypeInfo for MIME + extension hints.

Customization hook

Each method accepts optional Action<HttpRequestMessage> to append auth headers (Authorization: Bearer …), correlation ids, Accept overrides, or tracing headers.

Throws ApiException wrapping non-success status codes with contextual payload extraction (see class for available properties). ApiException derives from Lyo.Exceptions.Models.HttpException, so callers can handle it through the shared HTTP hierarchy: StatusCode and ErrorCode (populated from the first parsed LyoProblemDetails error code) come from the base type, and IsTransient is true for 408/429/502/503/504, which lets Lyo.Resilience retry pipelines pick it up automatically.

Options (ApiClientOptions)

Configuration section: ApiClientOptions.SectionName = "ApiClient". Integration-specific clients (Discord, Endato, ESPN, Typecast, …) subclass this type and shadow SectionName so all transport flags bind under their own section.

Property Default Description
BaseUrl null When set, becomes HttpClient.BaseAddress (trailing / enforced); relative URIs resolve against it.
EnsureStatusCode true Calls EnsureSuccessStatusCode after each response. Set false when the server returns problem-details bodies on non-success codes that the caller wants to inspect.
AcceptEncodings ["gzip","deflate","br"]* Sent as Accept-Encoding. *On netstandard2.0 the default drops br (Brotli is not built in there). Duplicates are removed and normalized to lowercase.
EnableAutoResponseDecompression true Enables HttpClientHandler.AutomaticDecompression for gzip/deflate/br when ApiClient creates its own handler.
RequestCompression None ApiRequestCompressionType for outgoing JSON bodies: None, Gzip, Deflate, Brotli. Sets Content-Encoding accordingly.
RequestCompressionMinBytes 1024 Minimum serialized payload size before compression applies (skips CPU on tiny bodies).

Pair request compression with a host that registers AddRequestDecompression (ASP.NET Core 7+) so the server can decode the body.

Compression and performance

  • Adds Accept-Encoding headers from AcceptEncodings (duplicates removed, case normalized).
  • Sets HttpClientHandler.AutomaticDecompression when EnableAutoResponseDecompression is true (maps gzip/deflate/br where the target framework supports Brotli).
  • Returns the underlying IHttpClientBuilder so callers can chain resilience, message handlers, or named-client overrides.

DI registration

clientName defaults to nameof(IApiClient) for named HttpClientFactory resolution. Bind from configuration with the standard services.Configure<ApiClientOptions>(config.GetSection(ApiClientOptions.SectionName)) if you prefer the section route.

Typical integration tests

Host the API with WebApplicationFactory, call through IApiClient, and assert ApiException.StatusCode plus ProblemDetails bodies using models from Lyo.Api.Models.

Dependencies

Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).

  • Lyo.Api.Models (direct, lyo)
  • Lyo.Common (direct, lyo)
  • Lyo.Diagnostic (direct, lyo)
  • Lyo.Exceptions (direct, lyo)
  • Microsoft.Extensions.Http 10.0.5 (direct, microsoft)
  • Microsoft.Extensions.Logging.Abstractions 10.0.5 (direct, microsoft)
  • Lyo.DateAndTime (transitive, lyo)
  • Lyo.Hashing (transitive, lyo)
  • Lyo.PackageMetadata (transitive, lyo)
  • Lyo.Query.Models (transitive, lyo)
  • Lyo.Result (transitive, lyo)
  • Microsoft.Extensions.DependencyInjection.Abstractions 10.0.5 (transitive, microsoft)
  • System.IO.Hashing 10.0.5 (transitive, microsoft, net10.0)
  • System.Memory 4.6.3 (transitive, microsoft, netstandard2.0)
  • System.Text.Json 10.0.5 (transitive, microsoft, netstandard2.0)
  • System.Threading.Tasks.Extensions 4.6.3 (transitive, microsoft)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (15)

Showing the top 5 NuGet packages that depend on Lyo.Api.Client:

Package Downloads
Lyo.Web.Components

Blazor components library for the Lyo web UI framework with MudBlazor integration.

Lyo.Config.Api.Client

HTTP client for the Lyo central Config API (conditional resolve, ETags, DI registration).

Lyo.Discord.Client

Discord API client for querying Discord data via the Lyo API.

Lyo.Job.Client

HTTP client for the Lyo Job API and IMqService-backed job event publisher for scheduler/worker hosts.

Lyo.Job.Scheduler

Job scheduling and execution service dispatching jobs via RabbitMQ message queue.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 11 8/20/2026
1.0.4 197 8/20/2026
1.0.3 182 8/19/2026
1.0.2 240 8/19/2026
1.0.1 349 8/18/2026
1.0.0 557 8/16/2026