I'm a new to RESTful API's and sort of developing my first one at the moment for a mobile application to be followed. I have a question regarding API versions and how to manage/tackle them.
At this moment, my API 'version' is a directory named v<version_name>
in which my API class resides. In that directory, I have resources that the API and REST client needs in another directory named include
. So the structure is as follows: example.com/api/v0.2/method_name/
and on .htaccess
, I'm making sure that everything that follows the API version (hardcoded in the .htaccess
file, is saved in a query string parameter).
I'm not sure if it is the right approach for a live application as it requires manually changing the URL endpoints at clients' ends, too. So my questions are:
- Is this the right approach to API versioning?
- If it is and I keep it, how do I deal with outdated URL's. Say for instance the app is live and I update the API to
v0.3
but the client who have the app installed would be accessingv0.2
and getting a 404 response code back? - Is there more elegant solution out there? It must be.
Edit: there are some resources that reside outside of the api
folder itself, in the root include
folder so to speak.
Edit 2: My API is targeted to be consumed by mobile applications and is not publicly consumable.