The Ops Community ⚙️

Divyessh Maheshwari
Divyessh Maheshwari

Posted on • Originally published at Medium on

Application Programming Interface

Have you ever wondered how can the frontend and the backend of an application communicate with each other? Or how do different apps extract data of other apps and websites like YouTube or Twitter?

All the applications that consist of a separate backend and frontend, have to use APIs ( Application Programming Interface ) to communicate with each other. The data transfer, logic processing, and other triggers take place through APIs only. If you want to know more about the backend of applications, you can check out this post by clicking here.

Today in this post, I am going to talk about APIs, and how they are used for different purposes and in different architectures. So let us begin.

Suppose you are a data scientist or a machine learning engineer, and you want to create a program to perform analysis over some youtube videos and channels, for example, you might want to predict the number of likes a video will get in a given time duration depending upon the number of subscribers of channel and data collected from previously posted videos. So in order to do that you will need a lot of data on the videos, as well as different channels.

Now in order to get so much data in bulk, you will be required to use the YouTube API, which will provide you a direct medium or bridge to all this data, and then you can simply extract it as per your use.

On the other hand, if you were not given access to this API, you would have done the same task manually or by creating a scrapper, and either of those methods would have been very inefficient and could have given trouble many times.

Types Of APIs

There are four different types of APIs depending upon their usage and accessibility. Let us study these in brief.

Open/Public APIs

These are APIs that can be accessed after getting a subscription or registration by developers. They have a low restriction and are generally used to access public data. Twitter API is one of the examples of public API since it enables users to get access to some public data which can then be used for different purposes such as educational projects, analysis, trends studies, etc.

Partner APIs

These are similar to Open APIs, although these are more restricted and are shared with limited partners after getting subscribed and approved by respective organizations.

Internal/Private APIs

These are not exposed publicly and are used internally among the system for different purposes like communication within the applications or system. They can also act as mediums for the frontend to communicate with the backend.

Composite APIs

These are generally a combination of multiple API endpoints and can be for the public as well as for internal use.

API Architectures

APIs also have a set of rules, structure, and format which defines their usage and operations. These are called its architectures or protocols. There are majorly three different protocols that we are going to discuss in this post.

Remote Procedure Calls (RPC)

“In distributed computing, a remote procedure call is when a computer program causes a procedure to execute in a different address space, which is coded as if it were a normal procedure call, without the programmer explicitly coding the details for the remote interaction. ~ Wikipedia

These were one of the oldest API calls and are generally used less in present-day applications.

Simple Object Access Protocol/Service-oriented architecture (SOAP/SOA)

“SOAP is a messaging protocol specification for exchanging structured information in the implementation of web services in computer networks. ~Wikipedia

These were structured API protocols but were very rigid and complex, and hence are not used often by emerging systems, but still used in many legacy applications.

Representational State Transfer (REST)

This is presently the most widely used architecture for APIs. It is primarily used in microservice architectures. It is highly flexible, cacheable, fast, efficient, and stateless architecture.

“REST has been employed throughout the software industry and is a widely accepted set of guidelines for creating stateless, reliable web APIs. A web API that obeys the REST constraints is informally described as RESTful. RESTful web APIs are typically loosely based on HTTP methods to access resources via URL-encoded parameters and the use of JSON or XML to transmit data. ~Wikipedia

So, now let us also understand what is JSON or XML.

Data Interchange Format

Data is transferred on the web in majorly two forms: JSON or XML. This can be data sent as request payload as well as response.

JSON (JavaScript Object Notation)

“JSON is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays. ~Wikipedia

JSON is language independent and allows to sharing of key-value pairs, arrays, or objects during web calls. It is readable and accessible as JSON objects and doesn’t need any further. So for example, if I have created an API that takes 2 numbers as input, and returns their sum as output. Then following can be examples of input and output.

XML (Extensible Markup Language)

“Extensible Markup Language is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. ~Wikipedia

XML data needs to be parsed before using and a similar example as above can be represented in XML as follows.


Now that we have a better understanding of APIs work, we can understand how these are created or implemented in different computer architectures. So to know more about the topic, just follow up with the post and stay tuned. I will keep adding different posts related to computer science concepts from a very fundamental point of view.

Top comments (0)