Demystifying API’s ( A Series..) ep.1
Hey Readers!
In this article, I will be writing about a term you’ve heard quite a bit! That term is API or APPLICATION PROGRAMMING INTERFACE.
In addition to knowing what an API stands for, I will be explaining what API does, why they exist and list the many benefits they provide.
This will be a Series ( this is probably episode 1, lol ), i will be starting from the very beginning so there is very little i am expecting you to know but just some basic programming knowledge and understanding of the web will do.
A.P.I, Quite a Buzz they generate, Don’t they ?
Let’s get to it
First let me give a clear breakdown of what is meant by APPLICATION PROGRAM INTERFACE. By understanding its purpose and its touch of history, you should be able to see and identify its purpose and begin to understand why this term keeps popping up in your life as a developer.
In my opinion, The best way to start learning about any acronym is to first understand each individual letter .
For A.P.I, let’s start with the last letter (I)
I Stands for interface, interfaces are all around us, let me give an example:
A simple radio has an interface that allows you to turn it on and off, increase the volume, change frequencies and do other operations without having any idea about what works inside or how it works. The individual controlling the radio is totally abstracted from the magic behind but still in control of what works based on the buttons available but not implementation-wise
This interfaces are so recognizable and they’ve even crawled their way into GUI ( Graphic user interface )
An example is the music player on our mobile devices where we play, record different music
We press different buttons on the mobile Application with no idea of how it works or play out the music to our hearing but we are all okay with that level of abstraction
The developer that coded this streaming music application definitely knows how the play button works, he/she coded the button so that when it gets clicked the music starts playing, Here is a thing though, the developer is also working with quite a few interfaces that are abstracting some of the details for the developer.
For instance, he wrote a code that happens when a button is clicked ( probably did that using an eventHandler ‘onClick’ on the button ) what he/she didn’t have to do however is to write a code that makes the button interact or change with the press ( it was already there for her ).
Buttons are in fact interfaces that provides or make available to the developer the means of controlling its interactions while abstracting away how that actually works implementation-wise.
This buttons e.g. a play button in a music streaming application ( as simple as it is ) is part of the API that is available from the application framework that was used in creating the application because most applications need buttons, this interface has been created to help the developer or application programmer to use easily.
By implementing the button interface, the developer was able to make the code Run when the button was clicked
It is worth knowing that the code probably also uses a ‘media player API’ that is provided by the operating system of the device being used ( Android, iOS… ), This API extracts away needing to understand the details on how to send audio data to the hardware, the developer knows he only wants to call the PLAY method of the MEDIA PLAYER API, the song is mostly not stored on the device, its been streamed over the network.
So, A web- based API call has been made over the internet to get the data.
A simple example below.
Let music = ‘Terminator-Asake.mp3’;
mediaPlayer.play(music);
Its actually API straight down all the way down to the 1’s and 0’s providing abstraction at all levels .
API have several things in common, They help us to interact or communicate with an object whether the object is physical or a software and as users of the interface we don't need to understand the implementation or how it works, we only need to know what we’ve been allowed to change or see ( interfaces extract away implementation )
Well, A simple clarification will be that the U.I ( user interface ) is meant for the user of the application while API is meant for the Application programmer to use and extend in their application
As a U.I ( user interface ) is to a simple user, So is an A.P.I for an Application programmer ( you dig, right ? )
An API is a contract of sorts that defines how it is expected to be used and what to expect as a response when used, it is basically a set of tools designed for software developers
API’s are everywhere in our software journey regardless of the language used in coding as each language has more than enough API’s to be consumed for different operations
Programming language specifications are just interfaces, Different operating systems can supply their own implementation so that the code works properly in their environment , Different operating systems works and maintain their files in totally different ways but yet your programming language provides a single API for working with the files ( you can run just one script and it runs on either MAc, Windows, linux ….bla bla bla, the implementation takes care of all the details.
The importance of an API to a language can not be understated.
Okay ( another angle ) there are different web browsers from chrome to safari to brave browsers and others and yet you can write code for the web an it works in any of them seamlessly, this works because there is a set of web API’s that web browsers all must implement in order to make that magic happen.
A big part of a software developer’s job is to figure out this tons of API available to us and use to our advantage and growth.
At this juncture, I End the first article in this series, the link to the next will be posted below
Cheers,
Thanks for reading!
Keep on levitating