---
title: "What is AddEndpointsApiExplorer in ASP.NET Core 6."  
description: "What is AddEndpointsApiExplorer in ASP.NET Core 6."  
author: "Utpal Vishwas"  
published: 2023-11-07  
updated: 2023-11-08  
canonical: https://www.mindstick.com/forum/160448/what-is-addendpointsapiexplorer-in-asp-dot-net-core-6  
category: ".net core"  
tags: ["asp.net core", ".net core", ".net core 6"]  
reading_time: 2 minutes  

---

# What is AddEndpointsApiExplorer in ASP.NET Core 6.

What is AddEndpointsApiExplorer in [ASP.NET Core](https://www.mindstick.com/articles/12946/get-started-with-asp-dot-net-core-mvc-and-visual-studio) 6.

## Replies

### Reply by Aryan Kumar

In [ASP.NET](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) Core 6, **AddEndpointApiExplorer** is an extension method that is part of the **Microsoft.AspNetCore.Mvc.Versioning** package. This method is used for configuring API versioning and API explorer (Swagger) in your ASP.NET Core Web API application.

API versioning is a technique that allows you to version your API endpoints, making it possible to introduce breaking changes or new features while maintaining backward compatibility with existing clients. API explorer, often implemented using Swagger, is a tool that generates interactive documentation for your APIs, making it easier for developers to understand and use your endpoints.

Here's how you can use **AddEndpointApiExplorer** in your ASP.NET Core 6 application:

**Install Required NuGet Packages**:

To use **AddEndpointApiExplorer**, you need to install the required NuGet packages:

```plaintext
dotnet add package Microsoft.AspNetCore.Mvc.Versioning
```

**Configure API Versioning and Explorer**:

In your **Startup.cs** file, typically in the **ConfigureServices** method, configure API versioning and API explorer as follows:

```plaintext
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Versioning;

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        // Configure API versioning
        services.AddApiVersioning(options =>
        {
            options.ReportApiVersions = true;
            options.AssumeDefaultVersionWhenUnspecified = true;
            options.DefaultApiVersion = new ApiVersion(1, 0);
        });

        // Configure API explorer (Swagger)
        services.AddVersionedApiExplorer(options =>
        {
            options.GroupNameFormat = "'v'VVV";
            options.SubstituteApiVersionInUrl = true;
        });

        // Other service configurations
    }

    // Rest of your Startup.cs
}
```

In this code:

**services.AddApiVersioning** is used to configure API versioning. You can specify various options like reporting API versions, setting a default version, and more.

**services.AddVersionedApiExplorer** is used to configure API explorer. You can set options for grouping and substituting API versions in URLs.

**Use API Explorer in Middleware**:

In your **Startup.cs** file, typically in the **Configure** method, configure API explorer for generating Swagger documentation:

```plaintext
public void Configure(IApplicationBuilder app, IApiVersionDescriptionProvider apiVersionDescriptionProvider)
{
    // Use API explorer to generate Swagger documentation
    app.UseSwagger();
    app.UseSwaggerUI(options =>
    {
        foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
        {
            options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", $"API {description.GroupName}");
        }
    });

    // Other middleware configurations
}
```

In this code, **app.UseSwagger** and **app.UseSwaggerUI** are used to enable the Swagger documentation and provide interactive API documentation based on the configured API versions.

Using **AddEndpointApiExplorer** in combination with API versioning and API explorer allows you to version your APIs and generate documentation to make them more discoverable and accessible for developers. It's a valuable tool when building and maintaining complex ASP.NET Core Web API applications with different versions.


---

Original Source: https://www.mindstick.com/forum/160448/what-is-addendpointsapiexplorer-in-asp-dot-net-core-6

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
