I'm starting a side project, the first stage will be a building a web application with MVC, in later stages we will be adding clients for mobile platforms. My thought was to create one API that all of the applications (web and mobile) go through to get/save data.
Because these different platforms will be on different release cycles I'll need a way for, say IPhone, to work with one version of the API while the website is using an updated version. What's the best way to do that?
My ideas so far are:
- Create a separate project to host the MVC Web API and host that in a subdomain or in a subfolder of the root site. Then either reference the DLL directly or reference it through the web (seems like an unnecessary http call)
- House the API within the MVC project that will be the website and try to version it based on url in there. I did some quick testing with that this morning and wasn't able to get it to work, it always resided at \api (I couldn't get it to reside at \api_v2)
Best Answer
In a large service with multiple consumers and integrated services, here's some principles and guidelines we followed to be RESTful over our web api. If you're not trying to be RESTful etc... and just want a simple http api, then it may not apply.
Key Principles:
We considered putting the version in the URL, but that breaks key RESTful principles.
https://stackoverflow.com/questions/389169/best-practices-for-api-versioning
Good read on web api design and versioning
What we did (basically, waving hands over details):
I am considering writing a blog and sharing how we integrated into web api to version our resources. If I do, I will follow up here with a link.