EngageLabs.MinimalApi 1.2.0

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

MinimalApi

A way to pack minimal APIs into configurable modules.

Continuous Integration

Continuous Deployment

Table of Contents

Description

This project aims to provide a minimal API framework that allows you to easily configure and organize your API endpoints into modules. It provides a simple and lightweight solution for building APIs with minimal overhead.

Usage

Create your module

To define a new module, just create a class inheriting from ApiModule and provide a Prefix for your endpoints and a body for the RegisterEndpoints method.

REMEMBER: All modules are already prefixed with api/ when they are registered in the application.

using EngageLabs.MinimalApi;

public class MyModule : ApiModule
{
    public override string Prefix => "my-module";

    public override void RegisterEndpoints(IEndpointRouteBuilder app)
    {
        app.MapGet("", async (PostsRepository repository) =>
        {
            var posts = await repository.GetPostsAsync().ConfigureAwait(false);
            return Results.Ok(posts);
        });

        // ...
    }
}

Register your module

To register all of your modules, just call the MapApi() extension method in Program.cs.

using EngageLabs.MinimalApi;

var builder = WebApplication.CreateBuilder(args);

// Your service registrations

var app = builder.Build();

// Your middleware

app.MapApi(typeof(Program).Assembly); // <-- Register api modules

app.Run();

The MapApi() extension method accepts 2 parameters:

  1. An assembly (or an array of assemblies) to scan and register all the modules and their related endpoints.

  2. A configuration action to define the behavior of the entire API. This is a good spot, for example, to configure application-wide logic like authentication, rate limiting, etc.

Customize your module

If you need to define some behaviors common to all the endpoints of the module, you can override the Configure method of the ApiModule base class. You will be provided with an IEndpointConventionBuilder to define your conventions for the module.

The Configure method is a good spot, for example, to configure OpenAPI information like name, description, tags (also used in the Swagger page), etc., or some behaviors that differ from the application-wide ones defined in the global configuration.

using EngageLabs.MinimalApi;

public class MyModule : ApiModule
{
    // ... Other module code ...

    public override void Configure(IEndpointConventionBuilder group)
    {
        // Your conventions here
        group.RequireAuthorization()
            .RequireRateLimiting("fixed"); // "fixed" must be a policy name registered via AddRateLimiter

        group.WithName("My Module")
            .WithDescription("My awesome API module")
            .WithTags("API Module");
    }
}

NOTE: A single endpoint can opt out of a module-wide convention with AllowAnonymous(): if you configure your module with RequireAuthorization() but add .AllowAnonymous() to one or more MapGet() calls in RegisterEndpoints, those endpoints bypass authorization entirely, regardless of the group's configuration. This is different from stacking multiple RequireAuthorization() calls, which are combined with an AND instead of overriding each other. See showcase app readme for more info.

Sample code

See the showcase app readme for an overview of the showcase app with some examples.

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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 145 9/3/2026
1.1.5 255 6/15/2026
1.1.2 107 3/21/2026
1.1.1 638 10/2/2025
1.1.0 192 10/2/2025
1.0.3 403 6/19/2025
1.0.2 581 9/12/2024
1.0.0 344 6/25/2024