efetch 8.0.0

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

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.

NuGet Version GitHub Tag NuGet Downloads


๐Ÿš€ 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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