If you have ever sent an online message, made an online payment or browsed your favorite search engine the chances are that you have already been introduced to APIs. But there’s more, so much more, to these seemingly transparent wonders.

The ‘Essentials’ series focuses on the ground-level understanding required to undertake the journey in to the world of APIs and will through the course of the series build upon your skills and introduce you to core concepts.  This series is intended for people who wish to gain a rudimentary understanding of APIs such as students, new software developers and managers wishing to gain understanding and experience within their team.

We have mentioned ‘API’ a few times now, but what is an ‘API’?

In school you learnt that ‘A’ is for apple but here the acronym refers to an Application Programming Interface.  It is no good to expand on just the acronym without some explanation as to its ideology or origin.

Application Programming Interface

Let us break down the terminology.

Application

Today scholars have developed an extensive definition for an ‘application’ and whilst this may be viewed with appreciation by like minded peers it is often disagreed with by those who have gained relevant industry experience or rendered trivial by those who work outside of the industry.

Suffice to say that in the late 70’s and early 80’s an application was simple.  It was a piece of computer code containing instructions which could be interpreted by a computer and executed to perform the desired function.  That definition describes the latest generation supercomputer as well as it describes the calculator but we know from experience that neither are similar.

Today with the advances in technology coupled with the intrusion of the Internet in to our daily lives an application is just about anything that can be interacted with.  Is a human or a car an application?  Of course not but then it is not in the context of software development either.

In the early days of software development (and really here I refer to the 70’s and 80’s) applications did not require much human input other than laboriously making out the punch cards.  These would be loaded in to the computer and some rudimentary input would be supplied and the function would then execute.  This was the basis of the computer – to compute or to derive an end result.

Programming

Computers (and to a large extent the evolution of the IT industry) is driven by two key aspects working in tandem.  On the one hand there is the microprocessor which is prevalent in everything from your PC through to your mobile phone, smart watch and network switches and routers.  The microprocessor gives life.  It is the quintessential component which allows the device to perform functions and tasks as required by its developers.

On the other hand is the application code which is written in a way so as to make use of the instruction set available on the microprocessor and to hardness its features.  Today microprocessors are quite complex and contain built-in interfaces for sound, video, graphics, memory and storage controllers so the instructions are plentiful.

Thus for the purposes of this definition ‘programming’ applies to the ability to issue the microprocessor with applicable instructions.  At a high level this definition is independent of operating system or programming language.

In a real-world scenario such as those practiced every day the ‘programming’ applies to using languages such as NodeJS, Java, PHP, Python, C, C++ and many others to issue instructions to the operating system which in turn executes these on the microprocessor.

Interface

Today unless you are a hard-core kernel developer or are working on an embedded device you almost never write code targeting a specific microprocessor directly.  Operating systems designed to work with the microprocessor, its instruction set and hardware peripherals abstract much of this effort away from the developer and provide these functions as high level interfaces.

An ‘interface’ is a mechanism that exposes a function to the developer allowing them to execute it in a safe and predictable manner.  In other words if you had a series of instructions that had to be called in a specific order, say the initialization of a hardware peripheral, you would wrap these instructions in to a logical grouping and expose it to the developer to be called as a single command in their application code.

If this was not done it would require a developer to be intimately aware of each instruction required to bring a device online or to execute a task.  Imagine if this was a printer and your application had to be aware of and execute each instruction for every blob of ink on the page.  That would be a very laborious program.  Instead developers convert information to a suitable format and send it to the printer using an interface saying ‘print this’.  The built-in code functions would then execute the instructions as required to produce the required result.

With this understanding we can begin deconstructing an API and it may be easier and more readily understood if we started with the interface.

Whether its pushing a button on our coffee machine, working on our computer or using our mobile device thousands of instructions are being sent and received between human and device and between devices themselves.  To accommodate these a mechanism is required to allow for the communication to occur in a standardized, safe and predictable manner.

This is the role of the interface which exists to allow for unidirectional or bidirectional communications and allows those communications to access and execute permissible and exposed functions.  In a real-world scenario this interface would exist to allow your Facebook messenger to send and receive messages between the web browser, Apple Iphone and Android devices all of which are distinctly different from each other.  In another sense an interface allows an application to query the built-in GPS to determine location information by merely using a library (a collection of interfaces and functions) rather than having to be programmed to support every available GPS chipset in every handset.

An interface cannot exist however without something providing it.  This is the role of the application which is written (programmed) in a specific language of choice and is usually supported by a framework (a collection of convenient functions which speed up code development).  Often this framework will have built-in mechanisms for creating interfaces or provide significantly simpler means of doing so.  Whatever the case the developer creates the relevant application code and functions and exposes these are interfaces either to be used internally by the same software or exposed externally for other software to use.

Software libraries (or .dll’s for the Windows aficionados) are a collection of interfaces which can be used in other applications.  In time we will learn about statically linked and dynamically linked libraries as well as libraries on Windows and Linux operating systems but for now it is enough to be aware of the nature and purpose of libraries.  Software libraries are convenient because it provides an essential architectural principal to developers: reusability.  With low-level and high-level functions encapsulated within libraries the developer is free to create the application instead of concerning themselves with perpetually repetitive intricacies.

Now we understand an API to be an application programming interface.  It is a mechanism that presents an interface to allow the safe and predictable execution of exposed and desired functionality.

APIs can take on various forms and there is no universal way in which they can be ratified.  It is dependent very much on the application and the nature and purpose of its use.  However in recent years standards have emerged in an attempt to give some form the way APIs are designed and documented as well as managed during operations.

Most commonly known to developers are the web API’s which govern everything from payment transactions, mobile apps and games to interactions between businesses (B2B) and consumers (B2C).  Lately standards for communication between machines (M2M) govern how card payment terminals or vehicle tracking devices communication.

In time we will learn more terminology but today you can proudly exclaim that you know what an ‘API’ is!

Was This Helpful?
All of the content on this site is presented without advertiser support and is produced exclusively by me. If you find any of this information useful please consider it against the cost of a course or book. I gladly accept donations of any amount which goes directly towards producing more quality content and videos for this site.

[wpedon id=119]
Written by YourAPIExpert