Why .NET introduced minimal API & why you should care about it?

When was Minimal API introduced?

Minimal APIs were introduced in:

  • .NET 6 (November 2021)

Before minimal API, for making independent & smaller services or microservices. A new web Api project needs to be created.

Because making simple microservice using Web API project has lot of boiler plate code before Minimal Api compared to other frameworks.

  1. Controller class

  2. Attributes

  3. Route configuration

  4. Startup class.

The boiler plate & code footprints were unnecessary for micro services & their docker files using.NET Web Api.

Node JS & Fast API framework already provided minimal Api like feature.

Node.js Express

app.get("/hello", (req,res)=>res.send("Hello")).

Python FastAPI

@app.get("/hello")
def hello():
    return "Hello"

Go HTTP

http.HandleFunc("/hello", hello)

So, for quickly creating microservices & improving their speed.

Hence minimal Apis was introduced in.NET to reduce boiler plate, improve speed & developer productivity.

.NET Minimal API

app.MapGet("/hello", () => "Hello");

They were part of Microsoft's push toward:

  • Simpler web development

  • Faster startup

  • Cloud-native microservices

  • Less ceremony

What Minimal API Reduced

Before

Typical microservice project structure:

Controllers/
Models/
DTOs/
Services/
Repositories/
Startup.cs
Program.cs
appsettings.json

Even a tiny service required many files.

After Minimal API:

Possible structure:

Program.cs
OrderService.cs
appsettings.json

Or even

Program.cs only

So, Minimal API reduced internal complexity, not deployment architecture.