API is a term we constantly throwing around in the software industry. APIs have become so fundamental to writing code that it's easier to be upset when a product doesn't offer an API, compared to being excited when it does.
In case you didn't know (or wanted a refresher), an API (application programming interface) provides a means to extend the functionality of an application for some other purpose, while only exposing what's necessary to developers. As I hinted, most popular applications have an API to some extent. Here are some examples in which an API could be used:
Most APIs today are dynamic. They run on a web server and are always changing. That makes them super powerful because they can be updated in real-time. But that also provides complications — they must employ proper caching mechanisms and (expensive) scaling methods as they acquire more concurrent users.
In addition, many APIs also require authentication so the app's developers know who is using their API and can allow, throttle, or charge those users as desired.
But an API doesn't have to be dynamic. An API could be static.
A dynamic API is an application, running on a web server, that performs actions for and delivers data (typically as JSON) to the requesting user.
A static API is simply a collection of flat JSON files that live on a content delivery network (CDN). It doesn't perform any action other than delivering content (static JSON files) to the requesting user.
But that doesn't mean a static API is simple. And every file doesn't have to be manually generated or updated. A static API can still use a database and it can still pull data from external services. In other words, it can be dynamically generated, but it is statically delivered.
If a dynamic API seems more powerful, that's because it is. But that power brings many challenges with it, and that power may not be something your API needs.
The advantages of using a static API largely follow the benefits of using the Jamstack. That makes sense, as a static API is basically a Jamstack website. Those advantages are:
As great as static APIs are, there are a few disadvantages when compared to their dynamic counterparts:
It sounds great in theory, but the static API approach is not always the practical (or wise) one to take. Here are a few examples in which a static API may make sense:
So there you have it — a static API.
While a dynamic API brings a lot of power, that comes with complexity, which often leads to a larger number of challenges, including cost, performance, security, and scale. In the right scenario, a static API can be just as powerful, while helping overcome those challenges.
Want to receive approximately one email every month with new articles, tools, and references I've discovered? Sign up below.