Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommended practices for Versioning WebAPI interfaces

I'd like to use WebAPI as my API technology to:

  • Allow approved companies to enter/retrieve data in my systtem
  • Create a standard interface for my company's iOS/Android/etc. applications

Does anyone know of best practices for, and mechanisms used to implement, versioning of interfaces. Specifically, I don't want to break backwards compatibility if I make updates to my API. I'd like to know what versioning schemes people use and if WebAPI has any built in mechanisms supporting versioning without the need to set up routes/paths every time a new version is released. Any thoughts would be appreciated.

Update After performing some research I think I know what I want to do, I'm not sure how to do it. Ideally during content negotiation I would like to use a media type passed by the user to specify which version of the API should be used (rather than hard-coding the URL) and hit the corresponding controller.

like image 498
JP. Avatar asked Jun 18 '12 17:06

JP.


2 Answers

If you don't want the version to be included in the Url, the way to go is probably to implement IHttpControllerSelector. This blog post should give you a good starting point: Implementing API versioning in ASP.NET Web API

like image 96
Christopher Avatar answered Oct 16 '22 06:10

Christopher


I recommend you take a look at Peter Williams' series of blog posts on versioning REST services. They explain the what and why. For the how, check out Mike Wasson's tutorial on how to create a custom media formatter.

like image 40
David Peden Avatar answered Oct 16 '22 05:10

David Peden