APIs are very powerful, but do you need to build your application as an API?
There’s a lot of ways to accomplish a task using ColdFusion. Some are elegant; some are not. Some involve a lot of steps, and some can be as simple as the page they exist upon. There’s many ways to skin a cat… and with the flexibility and power of modern programming languages, there are a myriad number of ways to accomplish any task.
As such, I had a developer recently tell me that “we need APIs for everything. The way to move forward is to build everything as an API without exception. I don’t care if it’s a contact form. Build it with an API.” This gave me pause. There are certain tasks, certain applications, and certain websites that building an API to interact with the database or separate the presentation layer from the data layer is simply overkill. And it made me ask the question; do I need an API?
There are a lot of arguments in favour of building all of your data interactions as API calls and becoming the greatest consumer of your own API. It’s consistent and uniform. It creates a hard separation between the data layer and the presentation layer. It gives you the flexibility to open your data to different sources. (Think about when your website expands and becomes an app and gets called from a mobile device.)
The cons… API’s aren’t a magic bullet. There’s the development cost in time and capital expenditure. If your company is small, building out applications as API’s may not be the way to go. Exposing data via API’s also bring inherent security risks that need to be managed.
For me, the bottom line becomes these fundamental questions;
- Do I have the time and budget to build this application as an API?
- Am I adding layers of unnecessary complexity to my application by making the data available and/or consuming that data by way of an API?
- Does my application need to be accessed from anything other than itself? Will it six months, a year, or five years from now?
A lot of times these answers are YES… and the API route is the way to go; but to use a blanket statement and say that all everything needs to be an API is, in my mind, thinking too big.