when you make a API, what is a better practice ?




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 ?

closed as primarily opinion-based by Kilian Foth, unholysampler, Bart van Ingen Schenau, Dan Pichelman, GlenH7 Nov 20 '14 at 21:32

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask – gnat Nov 20 '14 at 13:58

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.