From the course: Advanced Web APIs with ASP.NET Core 8

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Versioning options

Versioning options

- [Instructor] There are different ways how we can tackle API versioning, and these are the three most common ones. The first approach I'd like to discuss, and later also demonstrate, is to use a specific HTTP header for the API version. We will be using X-API-Version, but that's not a fixed name that you absolutely have to use. I've prefixed the HTTP header name with an X so that it's clear that it's an unofficial header name. Of course, you could pick something else and we'll see how that is set up. What we could also do is reuse an existing header, the Accept HTTP header, which usually tells the API which data type the client expects and the version could be part of that expected data type. We'll use the simple approach with the separate HTTP header for the version number though. Another approach would be to put the version number in the URL, for instance, like this, /v1.0/products. We are prefixing the path with the version number. That would help us to keep different API versions…

Contents