JanusRequest 2.0.0
dotnet add package JanusRequest --version 2.0.0
NuGet\Install-Package JanusRequest -Version 2.0.0
<PackageReference Include="JanusRequest" Version="2.0.0" />
<PackageVersion Include="JanusRequest" Version="2.0.0" />
<PackageReference Include="JanusRequest" />
paket add JanusRequest --version 2.0.0
#r "nuget: JanusRequest, 2.0.0"
#:package JanusRequest@2.0.0
#addin nuget:?package=JanusRequest&version=2.0.0
#tool nuget:?package=JanusRequest&version=2.0.0
JanusRequest
A typed HTTP client library for .NET with attribute-based routing, automatic serialization, fluent authentication, and built-in error recovery. Supports both sync and async APIs across .NET Framework 4.5+ and modern .NET.
Upgrading from v1.x? See the Migration Guide before updating.
Installation
Install-Package JanusRequest
Optional packages:
Install-Package JanusRequest.Extensions.DependencyInjection # IServiceCollection + IHttpClientFactory
Install-Package JanusRequest.Json.Newtonsoft # Newtonsoft.Json on .NET 5+
Quick Start
using JanusRequest;
using JanusRequest.Attributes;
// Define a typed request
[Request("/users/{id}")]
[ContentType(HttpContentType.Json)]
public class GetUserRequest : IRequestResponse<UserResponse>
{
[PathOnly]
public int Id { get; set; }
}
public class UserResponse
{
public int Id { get; set; }
public string Name { get; set; }
}
// Send it
using var client = new HttpApiClient("https://api.example.com");
var response = await client.GetAsync(new GetUserRequest { Id = 42 });
Console.WriteLine(response.Data.Name);
// Or use a simple URL overload
var response2 = await client.GetAsync<UserResponse>("/users/42");
Features
| Feature | Description | Wiki |
|---|---|---|
| Request Models & Attributes | [Request], [PathOnly], [QueryArg], [FormData], [Header], [Cookie] and more |
Attributes / Request Models |
| All HTTP Verbs | GET, POST, PUT, DELETE, PATCH + custom verbs, sync and async | HttpApiClient Reference |
| Authentication | Bearer, Basic, API Key, custom schemes, and IHttpAuthenticator |
Authentication / IHttpAuthenticator |
| Error Handling | HttpErrorHandler, ThrottleRecoveryHandler, RequestException |
Error Handling |
| Custom Deserializers | IResponseDeserializer<T>, [ResponseDeserializer] attribute |
Response Handlers |
| Logging | IHttpApiClientLogger with framework-agnostic lifecycle hooks |
Logging |
| JSON Serialization | System.Text.Json by default, Newtonsoft.Json opt-in |
Serialization |
| Dependency Injection | Default and named clients via IHttpClientFactory |
Dependency Injection |
| Headers & Cookies | Per-request headers/cookies via attributes or HttpRequestInfo |
Headers |
| Advanced Scenarios | Non-standard body methods, content types, query builder | Advanced Examples |
For full documentation, visit the Wiki.
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. 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 is compatible. 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 is compatible. 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 was computed. 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 | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. 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. |
-
.NETFramework 4.5
- Newtonsoft.Json (>= 13.0.1)
-
.NETFramework 4.7.2
- System.Text.Json (>= 8.0.5)
-
.NETStandard 2.0
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 8.0.5)
-
net5.0
- System.Text.Json (>= 8.0.5)
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on JanusRequest:
| Package | Downloads |
|---|---|
|
JanusRequest.Json.Newtonsoft
Optional Newtonsoft.Json integration for JanusRequest, providing an extension method to switch HttpApiClientSettings to use Newtonsoft.Json on .NET 5+. |
|
|
JanusRequest.Extensions.DependencyInjection
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Core improvements and integrations:
- Added configurable per-request timeout support
- Added support for non-standard body methods via NonStandardBodyMethods
- Improved absolute URL handling for request paths
- Extended RequestException to carry response headers
- Introduced IHttpApiClientLogger hook for structured logging
- Added generic RetryRecoveryHandler for transient failures
- Introduced media-type based content resolution with structured suffix support
(e.g. application/error+json falling back to application/json, with exact overrides winning)
- Made System.Text.Json the default JSON serializer for netstandard2.0+/net472+/net5.0+,
keeping Newtonsoft.Json only for legacy targets
- Added global content translator registration API for custom media types
- Improved non-success response handling to avoid deserializing empty/invalid bodies
when no HttpErrorHandler is registered
Attribute-driven headers and cookies:
- Added [Header] and [HeaderCollection] attributes for declaring HTTP headers on request properties
- Added IHeaderCollectionConvertible interface for custom header conversion logic
- Added [Cookie] and [CookieCollection] attributes for declaring HTTP cookies on request properties
- [Cookie] supports optional Path and Domain properties for cookie scoping
- Added ICookieCollectionConvertible interface returning IEnumerable<Cookie> for full cookie control
- [Header] and [Cookie] support AllowMultiple — multiple attributes on the same property
- Conflict validation: combining [Header]+[HeaderCollection] or [Cookie]+[CookieCollection]
on the same property throws InvalidOperationException
Error handling:
- Added DeserializationException (extends RequestException) thrown when response
deserialization fails, exposing Content, TargetType, and InnerException
- Fixed minor bugs and significantly expanded unit test coverage