What Are Minimal APIs?
Minimal APIs strip away controller ceremony and let you define endpoints directly on the WebApplication object.
Your First Endpoint
var app = WebApplication.Create(args);
app.MapGet("/hello", () => "Hello, World!");
app.Run();
Dependency Injection
Services are injected directly into route handlers — no constructor needed:
app.MapGet("/posts", async (IBlogService blog) =>
Results.Ok(await blog.GetPublishedAsync()));
💡
Minimal APIs are ideal for microservices and simple CRUD endpoints. For complex APIs with many action filters, stick with controllers.
OpenAPI Support
Add Swagger with a single NuGet package and two lines of code. Your API is documented automatically.
Conclusion
Minimal APIs are production-ready in .NET 10. Give them a try on your next greenfield project.