WTF is an API?

It took me an embarrassingly long time to really figure out what an API is.

This is what Wikipedia says:

In computer programming, an application programming interface (API) is a set of subroutine definitions, protocols, and tools for building application software. In general terms, it is a set of clearly defined methods of communication between various software components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer. An API may be for a web-based system, operating system, database system, computer hardware or software library. An API specification can take many forms, but often includes specifications for routines, data structures, object classes, variables or remote calls. POSIX, Microsoft Windows API, the C++ Standard Template Library and Java APIs are examples of different forms of APIs. Documentation for the API is usually provided to facilitate usage.

Clear? No? I wasn’t either…

Here is my non Wikipedia version:

API stands for Application Programming Interface. The word Interface is used to describe the point at which two systems communicate with one another across a boundary. In order to do this communication they require a defined language, this is what an API is. It is basically any language used to interact with a computer system.

The alternative would be writing code in zeros and ones, as that is fundamentally what all these clever computer things are doing under the hood. Anything else is an abstraction. Obviously that would be somewhat time consuming however.

One of the things that was confusing to me is that programming languages themselves are APIs. That is they are a set of methods that can be used to interact with a computer system. If you think of your TV as a system, then the API would be the TV remote. It has buttons, corresponding to things that you want the TV to do, such as ‘display guide’, ‘mute sound’ etc. After you have pushed a button, the TV will carry out a series of actions to reflect your instruction. How it does it is not available to you, or important to you. You only care that it does it according to the contract defined by the TV remote (I.E that pressing mute will turn off the sound on the TV).

Another thing that was VERY confusing to me is that in the wider world, when APIs are talked about, it is almost always in reference to an API, or set of methods, or language, for interacting with a web service. So for example, people will talk about ‘Google’s API’, or ‘British Airways’ API’. In these cases, they are referring to the defined language that is used to interact with these services, normally via HTTP. However, the principle remains the same. An API is a strictly defined language for interacting with another system. Aside from those constraints, it can take any form.

Leave a Reply

Your email address will not be published. Required fields are marked *