when you make a API, what is a better practice ?
http://webapp/api
or
http://api.webapp/
why ?
I started with the API in http://webapp/api
and the description of the service in http://webapp
. but now, I would like separate the description of the API in differents repositories, for this reason, I’m thinking in change the url API to http://api.webapp/
.
is a good idea/practice ?
1
One benefit of http://webapp/api
is that if you are developing the web site and the api as part of the same code base, you don’t really need to do any special handling to deploy the api – it’s just one web application that you have to deploy.
If you did use api.webapp
, for this case, then you would probably have to do some special handling during initial setup of the application.
For http://api.webapp/
on the other hand, you use a different host name in the url (assuming you also have a web application running at http://webapp/
).
This means that it could point to a different IP address – or it could point to the same IP – depending on DNS configuration. So by using this, you could have the api and web application be served by the same physical server to begin with, and later have the option of separating the two, without breaking your public interface!
So the first could be easier to setup initially, the latter gives you more options.