Tuesday, July 14, 2015

What the hell is an API ?

You all must have already read that boring definition of "What is an API" (well it is the accepted proper one though) , but did you really get it? 

A proper definition goes something like this,

API, an abbreviation of application program interface, is a set of routines, protocols, and tools for building software applications. The API specifies how software components should interact and APIs are used when programming graphical user interface (GUI) components.

[www.webopedia.com. 2015. What is Application Programming Interface. [ONLINE] Available at:http://www.webopedia.com/TERM/A/API.html. [Accessed 14 July 15].]

or something like this,

In computer programming, an application programming interface (API) is a set of routines, protocols, and tools for building software applications. An API expresses a software component in terms of its operations, inputs, outputs, and underlying types. An API defines functionalities that are independent of their respective implementations, which allows definitions and implementations to vary without compromising the interface. A good API makes it easier to develop a program by providing all the building blocks. A programmer then puts the blocks together.

[en.wikipedia.org. 2015. Application programming interface. [ONLINE] Available at:https://en.wikipedia.org/wiki/Application_programming_interface. [Accessed 14 July 15].]

Sigh.....

we do understand that , okay some of it, all right may be nothing, but that doesn't give you the satisfaction either right? are you confident after reading that definition ? you fully understood what is an API?  or what it does?

If no is your answer then let ME tell you what the hell is an API.

To understand about APIs, look at this two scenarios.

Without API.
With API.

Let us assume that you are going to design an app, this app will use google maps to get some co-ordinates.


Without API. 


Now as in scenario your app need to read some co-ordinates in a particular place. If you are not using any APIs, then your app need to go to google maps website ENTER the required location READ the webpage (as you would do) FIND matching details, EXTRACT and RETURN the details and then finally display.

Now if you are a programmer , software engineering student or a web designer then you already know how much lines of codes, time, effort and "OMG MY HEAD HURTS" thinking you need to go through to implement above ENTER,READ,FIND etc functions.

And also in case of google maps web site change their format or the structure, puuuf!! your app will not be able to understand the website to read and ultimately fail (boooo).

With API. 

If you read the definition, as it says APIs helps applications to interact/communicate with other applications. Therefore in this scenario we can use google maps API and make your app communicate directly in a structured way with the website and request a structured reply from maps.com.

For example using an API, your app can send a message to maps.com (in xml like structure) and the website will reply with information required in a similar structure.
Hence only thing you need to know is what is the code or what is the structure of the message/reply to send and get the particular information.

With the API, structure and coding will be documented upfront in the particular website , in this case in Google developers website. And most likely it does not change. Using an API not only save time and effort but also it is robust. It ensures your app to work even the format/structure of the website changes.

Now i think you have a better idea on what is an API and what it does. 
Thank you for visiting, Stay Awesome. Later.

P.S : It does not stop here, think about Java API , those are object oriented APIs, how they work is same as above, but if you want to know more about APIs, types of APIs and etc Wikipedia is good place to start.