AfterAcademy Tech
•
22 Oct 2019

Being a developer, we all must have come across a common term called “API”. We all must have used API in our project or must have heard of the term “API” from our team members while developing a project. But the question that arises here is “What is API?”. Is it some language or tool or framework or method or something else? What exactly is it? Don’t worry, in this blog, we will learn “What exactly is API?” in the best and easiest possible way. So, without wasting our time let’s get started.
To make the blog easier to understand for you, we have divided the whole blog into the following topics:
If you want to go through the video on “What exactly is API?”. You can watch here.
API stands for Application Programming Interface. To understand the meaning of API, we must have to understand the meaning of Interface. Let’s take a real-life example to understand the meaning of Interface and after learning interface, we will learn the meaning of API.

In the above image, you can see one radio having two knobs. One knob is responsible for changing the frequency of the radio channel to connect with different stations and the other knob is responsible for changing the volume of the songs played on the radio. Apart from the external things of the radio, there is some internal mechanism that is responsible for connecting your radio to different radio channels with the help of an antenna.
But if you think from the user perspective, you have only two options available with you i.e. either you can change the station on the radio or you can increase or decrease the volume of the music that is playing on the radio.
So, if you consider the radio as a system and yourself as the user of the system, then you are not bothered about the internal working of the radio. All you want is listening to music from different channels on the radio. That’s it. You are not going to connect wires to change the frequency or you are not going to add some registers to change the volume of the radio. All you need to do is just use the knob that will change the frequency and volume for you without performing any internal work on the radio.
In the above example, the radio is our system and it is providing two things i.e. two knobs for changing the frequency and for increasing/decreasing the volume. So, the radio here is an example of a system and the two knobs that are present on the radio are the APIs (Interface) for that system. You can consider the first knob that can change the frequency as API1 and the second knob that can change the volume as API2.
So, API is something which a system provides to the user so that the user can easily achieve what it wants, without bothering about the system architecture or the internal working of the system.
We have seen the conceptual point of view of API. Let’s look at some of the advantages of using API.
Till now, we have seen the conceptual point of view of APIs and some advantages of API. Now, in this section of the blog, we will learn API from a development point of view because this is most important. Everyone uses API in development. So, we must understand API from the developer’s view also. We can categorize the usage of API in development into the following categories:
Let’s learn all of them, one by one.
The software library is what you develop. For example, if you are writing some code for your Android application then, you will interact with the OS of Android. You have got various methods from the Android framework and with the help of those methods, you can interact with the OS.
So, in simpler words, if you have written some software library to achieve something and uploaded your library to GitHub or somewhere else, and if a user is using your software library with the help of methods that you have provided then it is called as API. Here, the user using your library is not bothered about the code of the library. He/she is only using the methods provided by you.
What does API means for procedural language and object-oriented language?
If you have written a library in some procedural language, then the user of your library will use a function (with various parameters) provided by you to get the desired output from the library. For example, if you have built a library to process an image, then the user can pass an image bitmap with filter flag to a function that produces an image by applying that filter on it.
For an object-oriented language, API from the software library and framework means the classes and their methods which are exposed by the library or framework to the user of that framework. The user only uses that methods and he/she is least interested in the internal working of the library.
In Android Framework, we have many libraries that are exposed to us. For example, to use a camera in an Android device, we can use the API provided by the Android Framework to capture an image.
An Operating System provides a way to interact with the system resources for an application through various exposed functions.
For example, if you want to write something on a file on your computer, then the operating system will provide you with a function that will open the file for you and you can read or edit it. All you need to do is pass the path of the file and the rest of the thing will be handled by the OS. You need not worry about the internal working involved in opening a file from the storage. So, the methods provided by the OS to interact with the system resources is APIs.
APIs can also be categorized from the perspective that how you are trying to access the resources. So, you can have remote APIs also.
For example, Java provides database connection framework which helps to connect databases which are functional in remote servers. The best part about this is you need not worry about the type of the database. For example, your database can be MySQL or PostgreSQL or something else. But with the help of methods provided to you, you can access the database of any type and can change accordingly.
Most of the time, APIs are referred from the perspective of the Web APIs and this is the most general context in which people talk about APIs. Web APIs comes into the picture when there is an interface between the enterprise and the application.
For example, you have your server and it is providing some services like streaming videos or accessing your social networks or something else. So, that enterprise will provide you with some APIs and with the help of those APIs, you can interact with those services present on your server.
To access the services provided by the enterprise, APIs provides URLs. So, form the Web perspective, if I am talking about API then it can be said that I am going to use HTTP protocol and in return, I am going to get the desired response.
In this part, we are going to learn about APIs from the web development point of view because APIs are mostly used in web development.
Basically, we create some web services and we provide means for the client to access these web services. Let’s understand this with the help of an example.

Suppose you are a company and you are having a list of products. So, if your user wants to get the list of products available in your company then you must provide some way or mechanism to do so. In this case, to access the web service i.e. the list of products, you will provide an API to the users or in simple words, you will provide an HTTP request because your user is trying to access the services over the internet.
So, you may be having a service running at your backend and you expose one method of that infrastructure that you have created which can be accessed by the HTTP request or simply a URL. The URL may look something like this:
http://company.com/flight?date=” ”
Here, you have to supply the below things:
In modern systems, these APIs plays an important role. Suppose you are an aggregator company and you have a web portal where a user can see the list of flights available from various companies. So, you can call the APIs provided by all the companies one by one and get the list of flights from all the companies. We can call multiple companies APIs here and in return, we can make a hybrid system.
In this blog, we learned a lot of things about APIs. We saw the conceptual view of API. We saw how developers should understand the concept of API. In the end, we saw the meaning of API from the perspective of web developers also. That’s it for this blog.
We hope you have understood what API is and how it is being used in the development environment.
Keep Learning 🙂
Team AfterAcademy!
AfterAcademy Tech
In this tutorial, we will learn to build the RESTful API using Node and Express. The goal is to make you comfortable in building your RESTful API with Node.js and Express. At the end of this blog, you will be able to build your REST APIs using Node.js and Express.

Janishar Ali
Nextjs is a very popular framwork for writing API backend services using Typescript (JavaScript). Building a secure and maintainable service requires understanding software concepts, dependency injection, abstraction, and integration with popular libraries. In this article we will deep dive and develop a complete project to power an actual mobile application.

AfterAcademy Tech
Write a program that, Given an array of n integers and given a number K, determines whether or not there exist two elements whose sum is exactly K.

Janishar Ali
Node.js backend architecture in Typescript. Learn the concepts behind building a highly maintainable and performant backend server application in ExpressJs. Implement a blog platform - role based APIs using JWT. ExpressJs, Mongodb, Redis, Joi, and Jest
