API featured image

What is an API?

Have you ever shopped at a place that promised lower prices, by cutting out the middleman? Although this might make things more comfortable in the real world by not having to deal with that cheesy storefront and high-pressure salesman. But that middleman is essential in the computer world.

The Wikipedia definition for API goes like this: “ An Application Programming Interface (API) is a set of functions, procedures, methods or classes used by computer programs to request services from the operating system, software libraries or any other service providers running on the computer.”

But Anyone hardly can understand this, right?

So, let’s dive deep into this:

What is an API:

Let’s consider software as a club sandwich-like stack of different programs, some of which sit between whatever program you’re interacting with directly and the hardware itself. Because without these layers programmers and developers would have to code differently for every single hardware configuration on the planet which would be impossible.

Other layers sit between two different pieces of other software and help them talk to each other without needing to have tons of code in common.

API diagram

These software layers help standardize the coding process so that programs can interface with lots of different stuff easily and while you might be most familiar with a layer called a Device driver, which translates program instructions and talks directly to your hardware. Another layer called an application programming interface, or API can be just as important.

We’ll think of it like this: Windows, Mac OS, and Linux all provide a graphical interface. Your buttons, checkboxes, menus etc. that are easy to click. Without that, you’d be left tediously typing commands for everything you want to do.

Like back in the days when DOS ruled the world, or if you’re a BASH fan than yesterday, similarly an API provides a more straightforward way for developers to interact with other kinds of software.

A perfect example of this is social media plugins that you see on certain websites. Such as a News article that embeds tweets, or a page that for better or for worse let people leave Facebook comments.

Both Twitter and Facebook have their APIs that they make available to web developers, making it easy for them to bake Twitter and Facebook features into their pages.

Without these APIs, these social media giants would have to share code directly with owners of other sites which would be tedious difficult and possibly give away certain trade secrets.

So, I think now that you have got some initial ideas of what an API is, let’s see how this works and functions in the real world.

How API Works?

Previously you read that API makes the life of developers and Enterprises easier, but how they work?

Think API as a messenger how takes your request and tells the system what you want to do and then returns the response to you.

Like if you want to share this particular in your favourite social media, then you click the button. And a popup opens, and your message gets shared.

This is not that easy.

When you press the button, you are requesting your social media, let’s say facebook to share this particular post. Then An Facebook API Takes your response and delivers it to the Facebook servers.

Then the Facebook servers return with a share this article response, and then a popup opens, and this article gets shared.

If you still cannot understand How API works, then let’s takes another example.

Think you are sitting in a restaurant, and you have a menu of choices to order from, and the kitchen is the part of the system that prepares your order and delivers the food back to you. But here’s something missing, right?

Yes, the connection between your table and the kitchen. Here comes the waiter or API, which makes your life easier by connecting your order to the kitchen and then taking and delivering the food back to your table.

Types of APIs:

Picking the right type of API is essential for any project. So, let’s see there how many types of APIs and their use cases.

1. Web APIs:

Web APIs or Web-based APIs or Web Services APIs are most commonly used in websites. The most commonly used web service APIs are REST, SOAP, XML-RPC and JSON-RPC.

2. Source-Code APIs:

Source code APIs offer libraries of objects, classes, etc. Source code APIs are often used in development projects to create a composite application. The calls are made according to the standards of the application environment, such as J2EE or .NET.

3. Legacy APIs:

A variety of legacy approaches to application interfaces employ flat files, remote object protocols, operating system interfaces, hardware APIs, communication protocols, message queues, and other means.

Referring to these as the legacy is not meant to be a pejorative, but rather a way of grouping a variety of long-standing and established, albeit somewhat older protocols together. An excellent example of Legacy API is CORBA or Common Object Request Broker Architecture.


I think this article has given you some ideas on what is an API and how it works. If you have felt that this article has helped you, then please share it with the world. And if you have any query, feel free to let me know in the comments. I reply to every single one.