Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

If I was working on a web application designing and writing an API how does that differ from a general web application development?

What things would I need to consider and take into account? Are there any standard processes to follow when creating an API that could be used by thousands of clients?

share|improve this question

marked as duplicate by gnat, Bart van Ingen Schenau, thorsten müller, Martijn Pieters, ChrisF Apr 7 '13 at 22:39

This question was marked as an exact duplicate of an existing question.

It depends.

In a recent project, I made the web application and the API nearly identical. If you had used by the web application as a page or through AJAX, the same request with the same URI would also be used through the API, only served with different MIME types (HTML or JSON type for the web application, JSON or XML for the API).

It works, and has its huge advantage: you write the code once. At least for the most part of the codebase, since there would be discrepancies. For example, it wouldn't make sense to use CAPTCHA in your API; on the other hand, the API would probably have a few additional calls that are not used by the web application.

You may as well designate the API in a very different way, distinct from your web application. This gives you for example the opportunity to have a RESTful API, while the web application would use sessions.

share|improve this answer

You could, for instance, have a web application that is entirely client side, and therefor does not require an API. One particular gotcha, is that browsers will limit you to only initiate HTTP GETs or POSTs, where as a RESTful API, for instance, may additionally require HTTP PUTs and DELETEs. As an example, the Ruby on Rails framework has a piece of Rack middleware that translates HTTP POSTs with a _method=[PUT|DELETE] parameter to the corresponding PUT|DELETE API call.

share|improve this answer

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