What is an API? – This is a very common question lot of ask while trying to understand on how different components interact with each other over internet.

API stands for Application Programming Interface which enables two software components to communicate with each other using a set of definitions and protocols.

These two software components can be within the same company infrastructure or they can be across two different infrastructure.

These are sometimes thought of as contracts that represent an agreement between the parties. Each component defines it’s own request and response structure without exposing any internal implementation. This information will be available in the API documentation of each module.

Types of APIs

Public APIs : These are also known as Public APIs. These are generally backed by OpenData. These can be accessed by anyone without any cost or charges. (Example: JSONPlaceholder API )

Partner APIs : Generally, while building system we end up integrating APIs from different partners for various use cases. These are called partner APIs ( Examples : SMS Gateway , Email notification , Payment Gateway ). This will have a onboarding process to obtain credentials / tokens which will be used while accessing the APIs

In the above diagram, Notification Service is accessing APIs of 3 different partners for sending different type of notifications. These are known as partner APIs

Internal APIs : These are also known as Private APIs. These are the APIs which are accessible only within the system and these will not have any authentication processes. These are completely hidden from external users

In the below diagram, account service is exposing an API to fetch account details of user by userId. This is an internal API which is called by other module ( Service 1 ) within the same system.

Composite API : These are the APIs which needs to interact with multiple modules within the system to provide the complete relevant data requested by the caller. This API required information from multiple sources to complete the single task

As per the above diagram, let’s say we need to design an API to provide user profile information along with account balance information in the single API call.

For this case, Service 1 has to interact with User Service to get profile information then, it has to interact with Account Service to fetch user balance. Once it has the data / information from both the API calls, Service 1 will combine them and respond to the caller in the predefined response structure.

Hope, this post will give an idea on the question – ‘What is an API?

Let’s look at What is API protocol?

By Admin