Minimal APIs are a concept that has been around for a long time in programming languages like Python or NodeJS. At their core, they allow developers to create tiny microservices and HTTPs APIs without having to delve into the depths of a framework.

The concept has now also established itself in .NET 6. Even though the creation of APIs was very well supported by the framework in the previous versions, minimal APIs take it to a new level. Especially for simple APIs, which should only receive data to process it later, these seem to be optimal, because they are easy to understand and to develop.

In this example we will learn how to create a minimal API project in Visual Studio 2022 from scratch and create a RESTful service. The idea is to provide an API for a classic use case, namely receiving a model.

  1. Create a new empty ASP.NET Core project in Visual Studio 2022
  2. Copy code from Minimal-API-.NET-6-Example/Program.cs at master · abierhaus/Minimal-API-.NET-6-Example (github.com)
  1. Run example
  2. Use the provided postman collection to start quering the API

You can find a full working copy here

Entrepreneur — technologist — passionate leader