The standard approach to API development is to build an application, include the user interface, back-end, etc. and then expose some, or all, of the functionality of the application through an API that draws on the existing code base. The design of the API is generally driven by the design of the application’s user interface. This approach may be called “consumer-first” development.
There are benefits to “consumer-first” development. For example, the needs of the end-user act as a specification. You can be sure that the scope of the API is sufficient to support business needs as the pre-existing application already supports those business needs.
However, there is no guarantee that an existing application provides all the functionality that might be required in an API. A successful API needs to support many applications, so does it make sense to base it on one? What usually happens is that the API is built by reference to one application and is then extended piecemeal as new applications uncover omissions in the original design. While this might be considered agile, it does mean that the APIs can start to lose coherence. Refactoring can help with this, but refactoring an API is an expensive business, as it has a downstream impact on everything that uses it.
API-First development, by contrast, starts with the API. It often takes into account wider concerns, such as company strategy, in determining what features should be provided. As the API is considered in this wider context, it is more likely to be consistent. Consistency is important in an API as it’s designed for use by developers, and consistency is one way of helping to manage complexity.
APIs designed using the API-First approach are more likely to be comprehensive. As they are developed in a context much wider than that of a single application, they are less likely to exclude areas of emerging importance—and hence are more likely to be future proof. Of course, the lack of a reference application may mean that they exclude important details, but it tends to be much easier to add detail than to add entire new functional areas.
While the API-First approach does not mandate specific technologies, there are some common standards emerging:
- RESTful web services allow developers to explore API using standard web browsers.
- SSL connections are becoming ubiquitous to protect data.
- JSON is replacing XML as the data exchange format.
We Recommended WPengine Hosting for WordPress