Introduction
API is abbreviated as APPLICATION PROGRAMMING INTERFACE. When we always take the word API it sounds complex but in reality, it’s very easy to use and understand! API is like a common language or interface used by servers to communicate with each other.

There are many types of devices and system configurations present in software eco System. They all need a common data format (language) to communicate With each Other.
Hence, we found a common way to deal with different devices. Therefore, developers started using the API. When we think about any type of web applications or software, they are all connected to remote servers. These applications need an interface to communicate with a server. Here API acts as an interface between them.

For example, When you type “www.codingninjas.in” into your web browser, a request goes out to codingninjas remote server, Then your browser receives a response back, it renders the information, and displays it in your browser.
Thus, Browser known as the client, and the Coding Ninjas server sends response through API. This means that when you visit any website on your browser you tend to interact with some remote server API. They are not the same as the server but it is a part of the server that receives requests and send responses.
API can be explained as a set of functions or subroutines or set of procedures or set of communication protocols, which is used to build software and applications.
Data Formats
API uses two different formats to transfer data:
- XML
- JSON
XML
XML (Extensible Markup Language) is a markup language (like HTML) which uses tags. We will embed the data inside the opening and closing tag.
The XML above is quite self-descriptive:
- It has sender information
- It has receiver information
- It has a heading
- It has a message body
Example:

JSON
JSON (JavaScript Object Notation) derived its name from JavaScript as it implements the same concept of Objects in the JavaScript. It uses a Key-Value pair to store the Data. From the Key, we can fetch its corresponding Data.
Example:

JSON VS XML
- XML is much more difficult to parse than JSON
- JSON is parsed into a ready-to-use JavaScript object
-
For AJAX applications, JSON is faster and easier than XML

Types Of APIs
There are four main types of APIs:
-
Open APIs
Also known as Public API, there are no restrictions to access these types of APIs because they are publicly available.
-
Partner APIs
A developer needs specific rights or licenses in order to access this type of API because they are not available to the public.
-
Internal APIs
Also known as Private APIs, only internal systems expose this type of API. These are usually designed for internal use within a company. The company uses this type of API among the different internal teams to be able to improve its products and services.
-
Composite APIs
This type of API combines different data and service APIs. It is a sequence of tasks that run synchronously as a result of the execution, and not at the request of a task. Its main uses are to speed up the process of execution and improve the performance of the listeners in the web interfaces.