APIEngine 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package APIEngine --version 1.0.2
                    
NuGet\Install-Package APIEngine -Version 1.0.2
                    
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="APIEngine" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="APIEngine" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="APIEngine" />
                    
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 APIEngine --version 1.0.2
                    
#r "nuget: APIEngine, 1.0.2"
                    
#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 APIEngine@1.0.2
                    
#: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=APIEngine&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=APIEngine&version=1.0.2
                    
Install as a Cake Tool

APIEngine

A lightweight, extensible .NET HTTP client foundation for building API wrappers with minimal boilerplate.

Includes built-in support for proxy configuration, flexible query parameter building, and JSON navigation helpers. Suitable as a base layer for automation tools, custom API clients, and microservice communication libraries.

Core Components

HttpApiClient

Abstract base class that encapsulates HttpClient configuration and standard HTTP verb methods. Handles:

  • Timeout configuration (default: 10 seconds)
  • Proxy setup (optional, with credentials support)
  • JSON serialization for request bodies
  • Error mapping – non-success status codes throw APIError exceptions automatically.
public class MyApiClient : HttpApiClient
{
    public MyApiClient(ProxyInfo? proxy = null) 
        : base("https://api.example.com", proxy) { }

    // Example: Custom request with default headers
    protected override Task ConfigureRequestAsync(HttpRequestMessage request)
    {
        request.Headers.Add("X-Custom-Header", "value");
        return Task.CompletedTask;
    }
}

ProxyInfo

Simple configuration object for HTTP proxies. | Property | Type | Description | |----------------|---------|--------------------------------------------------| | Host | string | Proxy server address (required) | | Port | int | Proxy server port (required) | | Username | string | Optional authentication login | | Password | string | Optional authentication password | | HasCredentials | bool | Computed; true if both Username and Password are set |

QueryParametersBuilder

Fluent builder to construct URL query strings, automatically skipping parameters that match their default values.

var query = QueryParametersBuilder.Create()
    .AddParameter("search", "hello")
    .AddParameterIf(page > 1, "page", page, defaultValue: 1)
    .AddParameter("limit", 10)
    .Build();
// result: "?search=hello&page=2&limit=10"

Special handling for:

  • Enum values – serialized as lowercase string (SomeEnum.Valuevalue).
  • Collections (List<int>, List<string>) – serialized as comma-separated values.
  • Null/defaults – parameters equal to their defaultValue are automatically excluded.

JsonExtensions

Helper methods for navigating System.Text.Json documents using dot-notation paths.

// Throws KeyNotFoundException if path is missing
var name = jsonElement.GetByPathOrThrow("user.profile.name");

// Safe access with Try pattern
if (jsonElement.TryGetByPath("error.message", out var errorEl))
{
    Console.WriteLine(errorEl.GetString());
}

Quick Start

// 1. Create a concrete client
public class CatFactsClient : HttpApiClient
{
    public CatFactsClient(ProxyInfo? proxy = null)
        : base("https://cat-fact.herokuapp.com", proxy) { }

    public Task<string> GetRandomFactAsync()
        => GetAsync("/facts/random");
}

// 2. Use it (with optional proxy)
var proxy = new ProxyInfo 
{ 
    Host = "127.0.0.1", 
    Port = 8080 
};

var client = new CatFactsClient(proxy);
var factJson = await client.GetRandomFactAsync();
Console.WriteLine(factJson);

Error Handling

Methods throw APIError when the server returns a non-success status code:

try
{
    await client.GetAsync("/restricted");
}
catch (APIError ex)
{
    Console.WriteLine($"HTTP {ex.StatusCode}: {ex.Message}");
    Console.WriteLine($"Raw body: {ex.RawResponse}");
}
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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on APIEngine:

Package Downloads
DeepSeekAPI

.NET client for DeepSeek Chat API

Px6API

.NET client for DeepSeek Chat API

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 113 5/23/2026
1.0.5 105 5/23/2026
1.0.4 131 5/18/2026
1.0.3 195 5/15/2026
1.0.2 114 5/12/2026
1.0.1 94 5/11/2026
1.0.0 92 5/11/2026