efetch 8.0.0
dotnet add package efetch --version 8.0.0
NuGet\Install-Package efetch -Version 8.0.0
<PackageReference Include="efetch" Version="8.0.0" />
<PackageVersion Include="efetch" Version="8.0.0" />
<PackageReference Include="efetch" />
paket add efetch --version 8.0.0
#r "nuget: efetch, 8.0.0"
#:package efetch@8.0.0
#addin nuget:?package=efetch&version=8.0.0
#tool nuget:?package=efetch&version=8.0.0
efetch
efetch is a lightweight C# library for performing resilient HTTP requests with minimal boilerplate. It supports GET, POST, PUT, PATCH, DELETE operations, built-in retry policies via Polly, customizable headers, and optional structured logging.
๐ Installation
Install via NuGet Package Manager:
Install-Package efetch
Or via .NET CLI:
dotnet add package efetch
โจ Features
- โ
Clean abstraction with
IEfetch
interface - ๐ Retry support using Polly
- ๐ฆ JSON deserialization with support for primitives, objects, and arrays
- ๐ก Simple query parameter handling
- ๐ Optional request/response logging
- ๐งฉ Built-in support for dependency injection
๐งฉ Configuration
Add to your app's appsettings.json
:
"Efetch": {
"BaseUrl": "https://api.example.com",
"DefaultHeaders": {
"Authorization": "Bearer YOUR_TOKEN",
"Accept": "application/json"
},
"RetryCount": 3
}
Register Efetch
in your DI container (Program.cs
):
builder.Services.AddEfetch(builder.Configuration);
๐งช Usage
Inject IEfetch
:
public class VaultController : ControllerBase
{
private readonly IEfetch _efetch;
public VaultController(IEfetch efetch)
{
_efetch = efetch;
}
[HttpGet]
public async Task<IActionResult> Get([FromQuery] string key)
{
var result = await _efetch.GetAsync<object>("vault", null, new() { { "key", key } });
return Ok(result);
}
}
๐ฆ Example
public class MyService
{
private readonly IEfetch _efetch;
public MyService(IEfetch efetch)
{
_efetch = efetch;
}
public async Task RunAsync()
{
// GET example
var result = await _efetch.GetAsync<MyResponse>("/data");
// POST example
var body = new MyRequest { Name = "John" };
var response = await _efetch.PostAsync<MyResponse, MyRequest>("/create", body);
// String response example
var plainText = await _efetch.GetAsync<string>("/version");
}
}
๐ API
IEfetch
GetAsync<T>(...)
PostAsync<T, TBody>(...)
PutAsync<T, TBody>(...)
PatchAsync<T, TBody>(...)
DeleteAsync<T>(...)
All methods support:
- Optional headers
- Optional query parameters
- Optional ID for REST-style routes
- Built-in retry policy
ILoggingProvider
Optionally implement your own logger or use the built-in ConsoleLoggingProvider
.
๐ง Advanced: Manual Configuration
builder.Services.AddSingleton(new EfetchConfig
{
BaseUrl = "https://api.example.com",
DefaultHeaders = new()
{
{ "Authorization", "Bearer abc123" },
{ "Accept", "application/json" }
}
});
builder.Services.AddTransient<IEfetch, Efetch>();
๐ค Author
efetch is created by Ethern Myth.
๐ License
Licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- Microsoft.Extensions.Http (>= 8.0.0)
- Polly (>= 8.3.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on efetch:
Package | Downloads |
---|---|
SecureSessionVault
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
8.0.0 | 221 | 5/23/2025 |