Lyo.Api.Client 2.0.0

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

Lyo.Api.Client

Lyo-specific HTTP client on top of LyoHttpClient. Non-success responses throw ApiException with RFC 7807 problem-details when the body parses. QueryProjectAsync / QueryConcreteAsync POST to {route}/QueryProject and {route}/QueryConcrete using Lyo.Query.Models only here.

Vendor clients (Endato, Typecast, ESPN, Discord, Google Maps) now inherit LyoHttpClient in Lyo.Http.Client. Config.Api.Client stays on ApiClient. Resolve via IHttpClientFactory.

Features

  • IApiClient / ApiClient. Subclass of LyoHttpClient. JSON verbs inherited; EnsureSuccessAsync maps problem-details to ApiException. User-Agent is Lyo/{version} (no UA rotation).
  • QueryProjectAsync / QueryConcreteAsync. POST {route}/QueryProject and POST {route}/QueryConcrete.
  • ApiRouteBuilder. Build(routePrefix, relativePath) applies the host's configured mount point, and WithIncludes(route, includes) appends one include query parameter per navigation to expand.
  • AddLyoApiClient. Factory registration for IApiClient plus optional correlation handler. Vendor AddLyoApiClient<T,T> is obsolete — use AddLyoHttpClient.

Examples

Register in DI

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

Register a vendor client

// Vendor packages call AddLyoHttpClient and return IHttpClientBuilder.
services.AddEndatoClientFromConfiguration(configuration)
    .AddStandardResilienceHandler();

IApiClient methods

Serialization

  • Effective JsonSerializerOptions come from GetSerializerOptions(). 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 the payload as the HttpClient already decoded it. Use AddLyoApiClient / LyoHttpClientHandler so gzip/br/deflate transport encoding is stripped. A stored .gz without Content-Encoding is left as-is.
  • GetFileStreamAsync returns Stream + filename + length without forcing memory spikes. Dispose the stream to release the response.
  • 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.

Non-success status codes throw ApiException wrapping 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)

Bind from ApiClientOptions.SectionName = "ApiClient". Clients for a specific integration (Discord, Endato, ESPN, Typecast, …) subclass the options type and shadow SectionName so transport flags land under that integration's 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 LyoHttpClientHandler.AutomaticDecompression for gzip/deflate/br when the client uses that primary handler (AddLyoApiClient / CreateHttpClient). Replacing the primary handler drops decompression unless the replacement sets it.
RequestCompression None LyoHttpRequestCompressionType 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).

Request compression only works if the host also registers AddRequestDecompression (ASP.NET Core 7+) and can decode the compressed body.

Compression and performance

  • Adds Accept-Encoding headers from AcceptEncodings (duplicates removed, case normalized).
  • Uses LyoHttpClientHandler as the IHttpClientFactory primary handler (UseLyoHttpClientHandler / UseLyoHttpClientHandler<TOptions>). Other typed clients (Config, etc.) should call the same helper instead of copying AutomaticDecompression setup.
  • JSON methods still sniff gzip/deflate magic bytes and strip a BOM. File/binary methods do not: they return whatever the handler already decoded.
  • A later ConfigurePrimaryHttpMessageHandler replaces decompression. Subclass LyoHttpClientHandler or set AutomaticDecompression on the replacement. Do not add a second decompressing DelegatingHandler.
  • Returns the underlying IHttpClientBuilder so callers can chain resilience, message handlers, or named-client overrides.

Register in DI

The default clientName is 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.

Vendor client registration (AddLyoApiClient<TClient, TOptions>)

Vendor clients (Endato, Typecast, ESPN Fantasy Football, Discord, Google Maps) inherit LyoHttpClient and register with AddLyoHttpClient<TClient, TOptions>, which returns IHttpClientBuilder.

The obsolete AddLyoApiClient<TClient, TOptions> overloads on this package forward to that factory path so older hosts still compile. Do not use singleton + GetService<HttpClient>().

Typical integration tests

Stand the API up under WebApplicationFactory, talk to it through IApiClient, then assert ApiException.StatusCode and ProblemDetails payloads with types from Lyo.Api.Models.

Dependencies

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

  • Lyo.Api.Models (direct, lyo)
  • Lyo.Common.Json (direct, lyo)
  • Lyo.Common.Metadata (direct, lyo)
  • Lyo.Configuration (direct, lyo)
  • Lyo.Diagnostic (direct, lyo)
  • Lyo.Exceptions (direct, lyo)
  • Lyo.Http.Client (direct, lyo)
  • Lyo.Metrics (direct, lyo)
  • Lyo.Query.Models (direct, lyo)
  • Microsoft.Extensions.Http 10.0.5 (direct, microsoft)
  • Microsoft.Extensions.Logging.Abstractions 10.0.5 (direct, microsoft)
  • Lyo.Common.Core (transitive, lyo)
  • Lyo.DateAndTime (transitive, lyo)
  • Lyo.Hashing (transitive, lyo)
  • Lyo.PackageMetadata (transitive, lyo)
  • Lyo.Parameters (transitive, lyo)
  • Lyo.Result (transitive, lyo)
  • AngleSharp 1.5.0 (transitive, third-party)
  • Microsoft.Bcl.AsyncInterfaces 10.0.5 (transitive, microsoft, netstandard2.0)
  • Microsoft.Extensions.Configuration.Binder 10.0.5 (transitive, microsoft)
  • 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.RateLimiting 10.0.5 (transitive, microsoft)
  • 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 (16)

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, HTTP IConfigStore over manage routes).

Lyo.Job.Client

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

Lyo.Authentication.Web.Components

Host-agnostic Razor / MudBlazor pages for Lyo authentication: provider login, JWT debug workbench, and user profile (self + other). Pair with `Lyo.Authentication.Web.Components.Server` (BFF cookie flow) or `Lyo.Authentication.Web.Components.Wasm` (direct token flow).

Lyo.FileStorage.Web.Components

Reusable Blazor components for file storage: upload/save, path tree browser, DEK/KEK migration and rotation, metadata/expected-storage browser grids.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 200 9/9/2026
1.0.13 734 8/25/2026
1.0.11 840 8/23/2026
1.0.10 163 8/22/2026
1.0.9 905 8/22/2026
1.0.6 1,017 8/20/2026
1.0.4 1,108 8/20/2026
1.0.3 813 8/19/2026
1.0.2 851 8/19/2026
1.0.1 794 8/18/2026
1.0.0 715 8/16/2026