API - From a Freshman's POV

API - From a Freshman's POV

Connectivity is a phenomenal power we've got. Today, the whole world is connected by some or the other means. Technologically these mediums are desktops, mobile phones, tablets, smart wearable devices and the list goes on. But how does this all happen, how does data gets from one point to another? How does different devices and applications connect with each other and how does they allow us to shop, book a flight and order food? Speaking in Ajay Devgn's style, the unsung worrier of this scenario is the API.

What is an API?

What is an API

via GIPHY

Application Programming Interface or the API is working under the hood, or behind the scenes which we generally taken for granted. It is responsible for all the connectivity which we expect and rely on. But what API really is?

In technical terms, "An application programming interface (API) is a set of protocols, routines, functions and/or commands that programmers use to facilitate interaction between distinct software services."

In laymen terms, an API is just a messenger that works to deliver messages between you and the system. It takes a query from you, takes it to the system, resolves it and bring back the desired response you expect. Still got a question that why should we use an API when the frameworks already has a connection between the front-end and back-end? Let's understand this with an easy example.

Example 1

Example 1

via GIPHY

Suppose you are at a restaurant, sitting at your table reading the menu. There is a kitchen far from you where food is being cooked. You chose a dish and decided to order it, what would you do next? Obviously you will call the waiter, who then takes your order, get it to the chef, then the chef prepares your dish which the waiter bring back to you.

In this example you were the user, your dish was your request, the kitchen worked as a system and the waiter was the API. Now let's get it through a programmer's life example.

Example 2

Example 2

via GIPHY

Let's assume you are a Django developer and you are working on a banking website project. Working on each and every component of the application from scratch and hard coding every little thing would be a hectic job. From somewhere you came to know that your friend has already made a EMI calculator in react js which you can make use of for your project. But the problem here is, how to use react components in Django, nor your friend is willing to share the logic of the calculator.

In this case, the best solution for this is that, your friend creates an API and share the endpoints with you. By performing various HTTP requests over that API you easily would be able to get the work done along with your friend abstracting the actual code. This is the power of API.

Now you are in the position of explaining what an API is. Let's look at one of the real world use cases of API.

Hotel Booking Service

Hotel Booking Service

via GIPHY

You must have heard of trivago. It is a metasearch engine that compares accommodation prices and offers provided to us by many different online booking sites. They compare and display different offers from many booking sites, who then pays trivago a fee if a we click on their specific deal. But from where trivago collects all this data?

FastConnect is the hotel search API that establishes a direct interface between the reservation system and trivago to pull real-time hotel rates and availability.

How can you make use of API

How can you make use of API

via GIPHY

Let's say you are developing a chat application. In that you added a feature for sending GIFs. One way you can develop your own GIF library from where the users can search and send GIFs, but this is not an optimal solution. The other way is that you can make use of the GIPHY API and by using their endpoint you can easily get access to the collection of millions of GIFs library which would save a lot of time.

Hope you're able to see the clear picture of the term API from a Freshman's POV. For more such articles subscribe to our newsletter service so you won't miss an update regarding our next post. Keep reading, Keep exploring, Keep learning.