Api: How use multi api version in Laravel 5?

Created on 13 Apr 2016  路  4Comments  路  Source: dingo/api

Hi,
I have an example API for: web app, android app, ios app,..
I want a lot of different versions to run in parallel.
Ex:
/api/v1/auth for web app
/api/v2/auth for web app

/api/android/auth for android app
/api/ios/auth for ios app

What I have to do?

Tks all.

discussion

Most helpful comment

@tronghiep92 If you are talking about versioning the API in the URL, I'm in your team. There is always a debate whether the version of the API should be sent in the URL or in headers.
Read this, this and this to have a more clear idea why is considered a best practice to have the version in the URL.

Now, with the endpoints for each platform that you mentioned:

/api/android/auth for android app
/api/ios/auth for ios app

You are wrong in that one my friend. APIs shouldn't be specific made for a given platform (android, ios, web). The idea is that the API will provide with information to the "client", in the API-side you should not worry about WHO is going to use the API, nor in which platform, nor with which codding language will consume it.

All 4 comments

Why do you need to do that in the first place?

I think you should specify in Accept header rather than url

@tronghiep92 If you are talking about versioning the API in the URL, I'm in your team. There is always a debate whether the version of the API should be sent in the URL or in headers.
Read this, this and this to have a more clear idea why is considered a best practice to have the version in the URL.

Now, with the endpoints for each platform that you mentioned:

/api/android/auth for android app
/api/ios/auth for ios app

You are wrong in that one my friend. APIs shouldn't be specific made for a given platform (android, ios, web). The idea is that the API will provide with information to the "client", in the API-side you should not worry about WHO is going to use the API, nor in which platform, nor with which codding language will consume it.

So, technically this package will work with both versioning schemes, but you'd still need to utilize the Accept header versioning technique to access the different version groups. You'd have redundant versioning information though.

Was this page helpful?
0 / 5 - 0 ratings