
March 6, 2025 05:54 by
Peter
Having well-organized and aesthetically pleasing API documentation is essential in modern web development. For creating visually appealing API documentation for ASP.NET Core applications, Scalar is a great tool. The easy integration of Scalar into an ASP.NET Core project and the creation of API documentation will be covered in this post.

Scalar: What is it?
An open-source tool for API documentation, Scalar offers a user-friendly and aesthetically pleasing interface for testing and researching APIs. It is a straightforward and user-friendly substitute for Redoc and Swagger UI.
Why Use Scalar for API Documentation?
- User-friendly Interface: Scalar provides a clean and modern UI.
- Interactive API Testing: Allows developers to test APIs directly from the documentation.
- Easy Integration: Simple setup process with minimal configuration.
- Open Source: Free to use and modify according to project needs.
Setting Up Scalar in ASP.NET Core
Step 1. Install Scalar Package
To integrate Scalar into your ASP.NET Core project, you need to install the Scalar NuGet package. Run the following command in the terminal.
Install-Package Scalar.AspNetCore
Step 2. Configure Scalar in Startup.cs.
Modify the Startup.cs file to add Scalar middleware.
using Scalar.AspNetCore;
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddScalar();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseScalar(); // Enable Scalar documentation
}
Step 3. Access API Documentation.
Once the configuration is complete, run your ASP.NET Core application and navigate to the following URL.
https://localhost:<port>/scalar
You should see a beautifully generated API documentation interface.
Customizing Scalar Documentation
Scalar provides customization options to enhance the API documentation experience.
1. Adding API Metadata
You can customize API metadata such as title, version, and description by modifying the Scalar configuration.
services.AddScalar(options =>
{
options.DocumentTitle = "My API Documentation";
options.ApiVersion = "v1.0";
options.Description = "This is a sample API documentation using Scalar.";
});
2. Securing API Documentation
You can use authentication middleware to secure the Scalar endpoint and limit access to your API documentation.
Conclusion
With ASP.NET Core, Scalar is a potent tool for producing visually appealing and interactive API documentation. It is a great substitute for more conventional documentation tools like Swagger because of its simplicity of integration, intuitive interface, and customizable features. You may rapidly set up Scalar and enhance your experience with API documentation by following the instructions in this article.