This morning MagicMerl pointed me to a great post by Kas Thomas called API First Design. Clearly, there are benefits to developing your APIs at the same time as you develop your web app. As I commented:
"API First" is spot-on - the way we at Mashery describe it is that a developer should be able to build any or all functionality of your website through your API, and that your web app actually runs on the same APIs (and therefore the same codebase) that you make available to third party developers.
The advantages of this approach are obvious:
- a single codebase to maintain
- no additional work to open the API (through Mashery, of course :) - since you will need to create rules around which developers are authorized to use which API methods if all services are built as APIs)
- consistent behavior across the API and the web app. I have seen search APIs that return different results for the same search depending on whether that search comes in through the API or the web page; this makes developing apps difficult, since you can't test and debug different searches on the website.
- by opening the full set of services through APIs, you are providing the broadest possible toolset for third party developers to use in building apps, and you will see way more innovation than if you limit your APIs to a subset of services.
So even if it is too late to be "API First", we strongly recommend that you "Open Everything" as quickly as you can, even if doing so takes time. The New York Times is setting a great example of how this is done - since opening their first API last October (campaign finance data), they have steadily opened more and more services over the past few months, and will continue doing so until everything is open. They have publicly announced their commitment to opening everything, so developers know that there will be new and exciting building blocks coming down the road.