In recent years, Application Programming Interfaces (or API for short) have become a mainstay of countless web projects, used by many coders and programmers to extend web services – but just what is an API, how do they work, and how can they benefit you and your users? Below is a beginner’s guide to the wonderful world of APIs.
You already use APIs, probably without realizing it
Without even realizing it, most of us already benefit from using software APIs almost daily. For example, if you’ve ever played a game or used a third-party app on Facebook, it will have most likely been built using Facebook’s open-source API. Any system that releases part of its underlying code to other developers – whether that be just data or its actual operating code – will, in most cases, do so through an API.
To get a better idea of how APIs work, it’s probably best to look at the function they provide. When websites are built, they are constructed using code – most often fiercely protected code to stop others from stealing the valuable source data.
However, if a company builds an API, it essentially gives access to parts of its source code to allow other developers to tie in with or extend its existing services – perhaps to serve data or to build extra, stand-alone applications. An API is essentially an intermediary piece of software that allows two apps to communicate with each other.
So, using the Facebook example above, the company reached out to the developer network in 2007 by exposing some of its course code to allow programmers to build their own apps that could run in the Facebook walled garden environment. In this case, it was a very shrewd decision as it massively increased the number of services Facebook could offer – but without the burden of having to develop the apps themselves.
APIs are now an integral part of many web projects, allowing an originating company to extend its services massively without altering its existing code. By using APIs, third-party developers can draw on a company’s original code to bring extra services. For example, the Octopart API allows other websites and web services to pull in its extensive database of electronic parts, meaning the company can extend its customer base by offering hard-to-find products on an external website.
A real-world example of an API at work
A real-world example perhaps gives a better insight as to how APIs work. Imagine the scenario that you’ve sat down at a restaurant to eat. Your server approaches you with the menu, you decide what you want, and then give your order to the server.
The server then relays your order to the kitchen, where the food is prepared. In this scenario, you (the client) make a request but, without the server (the API), the kitchen (in this example, the system) won’t know what you want. The server is the essential link between you and the kitchen – in much the same way that an API is an interpretive software between web services, apps, databases, and websites.