Soenneker.Blazor.ApiClient
4.0.3085
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Blazor.ApiClient --version 4.0.3085
NuGet\Install-Package Soenneker.Blazor.ApiClient -Version 4.0.3085
<PackageReference Include="Soenneker.Blazor.ApiClient" Version="4.0.3085" />
<PackageVersion Include="Soenneker.Blazor.ApiClient" Version="4.0.3085" />
<PackageReference Include="Soenneker.Blazor.ApiClient" />
paket add Soenneker.Blazor.ApiClient --version 4.0.3085
#r "nuget: Soenneker.Blazor.ApiClient, 4.0.3085"
#:package Soenneker.Blazor.ApiClient@4.0.3085
#addin nuget:?package=Soenneker.Blazor.ApiClient&version=4.0.3085
#tool nuget:?package=Soenneker.Blazor.ApiClient&version=4.0.3085
Soenneker.Blazor.ApiClient
Defines methods for configuring and interacting with the API, including HTTP operations, authentication, and optional request/response logging.
Install
dotnet add package Soenneker.Blazor.ApiClient
Quick start
using Soenneker.Blazor.ApiClient.Registrars;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
var result = services.AddApiClientAsScoped();
Adds IApiClient as a scoped service.
What you get
IApiClient— Defines methods for configuring and interacting with the API, including HTTP operations, authentication, and optional request/response logging.ApiClientRegistrar— A lightweight and efficient API client wrapper for Blazor applications, simplifying HTTP communication with support for asynchronous calls, cancellation tokens, and JSON serialization.RequestOptions— Represents the options for making an API request, including the URI, request payload, and logging settings.RequestUploadOptions— Represents the options for uploading a file via an API request, extendingRequestOptionswith additional file upload properties.
API at a glance
| API | What it does | Result / important behavior |
|---|---|---|
IApiClient.Initialize(baseAddress, requestResponseLogging) |
Initializes the client with the specified base address and logging setting. Must be called before performing any HTTP operations. | Returns no value; the requested change is complete when the method returns. |
IApiClient.GetClient(allowAnonymous, cancellationToken) |
Retrieves or creates an HttpClient instance configured for authenticated or anonymous requests. |
A task that returns the configured HttpClient. |
IApiClient.GetAccessToken(cancellationToken) |
Requests and returns a fresh access token using the configured authentication provider. | A task that returns the access token string. |
IApiClient.Get(uri, allowAnonymous, cancellationToken) |
Sends a GET request to the specified URI. | A task that returns the HttpResponseMessage. |
IApiClient.Get(options, cancellationToken) |
Sends a GET request using the specified RequestOptions. |
A task that returns the HttpResponseMessage. |
IApiClient.Post(uri, obj, logResponse, allowAnonymous, cancellationToken) |
Sends a POST request with a JSON-serializable payload. | A task that returns the HttpResponseMessage. |
IApiClient.Post(options, cancellationToken) |
Sends a POST request using the specified RequestOptions. |
A task that returns the HttpResponseMessage. |
IApiClient.Put(uri, obj, allowAnonymous, cancellationToken) |
Sends a PUT request with a JSON-serializable payload. | A task that returns the HttpResponseMessage. |
IApiClient.Put(options, cancellationToken) |
Sends a PUT request using the specified RequestOptions. |
A task that returns the HttpResponseMessage. |
IApiClient.Delete(uri, cancellationToken) |
Sends a DELETE request to the specified URI. | A task that returns the HttpResponseMessage. |
IApiClient.Delete(options, cancellationToken) |
Sends a DELETE request using the specified RequestOptions. |
A task that returns the HttpResponseMessage. |
IApiClient.Upload(options, cancellationToken) |
Uploads a file stream with optional JSON metadata. | A task that returns the HttpResponseMessage. |
ApiClientRegistrar.AddApiClientAsScoped(services) |
Adds IApiClient as a scoped service. |
The same service collection, so additional registrations can be chained. |
RequestOptions.Uri |
Gets or sets the URI for the API request. | Gets or sets the URI for the API request. |
RequestOptions.Object |
Gets or sets an optional object that will be serialized and sent as the request body. | Gets or sets an optional object that will be serialized and sent as the request body. |
RequestOptions.AllowAnonymous |
Gets or sets a value indicating whether the request should allow anonymous access. Defaults to null (false). | Gets or sets a value indicating whether the request should allow anonymous access. Defaults to null (false). |
RequestOptions.LogResponse |
Gets or sets a value indicating whether the response should be logged. Defaults to null (false). | Gets or sets a value indicating whether the response should be logged. Defaults to null (false). |
RequestOptions.LogRequest |
Gets or sets a value indicating whether the request should be logged. Defaults to null (false). | Gets or sets a value indicating whether the request should be logged. Defaults to null (false). |
Important behavior
IApiClient.GetAccessToken(cancellationToken): Thrown if the user is not authenticated or if the token could not be acquired.
Practical notes
- Cancellation stops pending work; it does not undo work that has already completed.
| Product | Versions 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. |
-
net10.0
- Soenneker.Blazor.LogJson (>= 4.0.1872)
- Soenneker.Blazor.Utils.Session (>= 4.0.2694)
- Soenneker.Extensions.Object (>= 4.0.4300)
- Soenneker.Utils.HttpClientCache (>= 4.0.2031)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Soenneker.Blazor.ApiClient:
| Package | Downloads |
|---|---|
|
Soenneker.Blazor.Consumer.Base
An abstract wrapper around Soenneker.Blazor.ApiClient supporting auto (de)serialization for requests/responses/ProblemDetails. |
|
|
Soenneker.Blazor.Consumers.Core
A class that represents the core Blazor Consumer, providing no additional functionality than access to Soenneker.Blazor.ApiClient |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.3092 | 0 | 8/30/2026 |
| 4.0.3091 | 0 | 8/30/2026 |
| 4.0.3090 | 0 | 8/30/2026 |
| 4.0.3088 | 0 | 8/29/2026 |
| 4.0.3085 | 23 | 8/29/2026 |
| 4.0.3084 | 27 | 8/29/2026 |
| 4.0.3083 | 35 | 8/29/2026 |
| 4.0.3082 | 129 | 8/26/2026 |
| 4.0.3081 | 125 | 8/26/2026 |
| 4.0.3079 | 63 | 8/26/2026 |
| 4.0.3078 | 120 | 8/26/2026 |
| 4.0.3077 | 99 | 8/26/2026 |
| 4.0.3076 | 83 | 8/25/2026 |
| 4.0.3075 | 70 | 8/25/2026 |
| 4.0.3074 | 193 | 8/22/2026 |
| 4.0.3073 | 115 | 8/22/2026 |
| 4.0.3072 | 162 | 8/22/2026 |
| 4.0.3070 | 81 | 8/21/2026 |
| 4.0.3069 | 90 | 8/21/2026 |
Improve README usability and API guidance