What is API and its Usage ? :[4 Types of APIs]

Introduction

In this tutorial we will learn about what is API and its usage with 4 types of APIs category. APIs are categorized purely based on their use cases, target end users and accessibility. We will look at the very basic definition of API in the next section followed by their usage and examples.

 

What is API and its Usage ? :[4 Types of APIs]

What is API and its Usage ? :[4 Types of APIs]

Also read:  How to Build Port Scanner using Python: [2 Easy Examples]

API Overview

APIs is Application Programming Interfaces. The interface is the contract with which two separate programs agree upon to communicate with each other. These communications takes places based on a set of rules and protocols like HTTP. They are essential for building software that can interact with external services, libraries or data sources. There are various types of APIs available, each serving different purposes.  The choice of which type of API to use depends on the specific business requirements, audiences and security considerations.

 

Let us understand API with an example. Let’s say you are developing an application where you want to store all the data from your website(Application A) to a database( Application B).

In this diagram, Application A(Website) wants to send data to Application B(Back-end service) for storage. To do this, Application A and Application B will agree upon a certain set of protocol or interface on how the data will be sent along with the format of data. Once the interface is agreed upon, the developer will write the code so that the data is sent in the correct format and with the agreed communication protocol. Since here, the data flow for an application happens via an interface and interface is developed using a program, hence it is called  Application Programming Interface.

 

Types of APIs

Also read: [Solved]: Hacker Rank FizzBuzz Problem

You must have noticed that whenever you open any website in your browser, you get a page opened in response. This response is sent by Web APIs. So when we talk about API, we refer to sub category of API called Web APIs. Web API has been broadly categorized into four categories . These are categorized based on different business  use cases, accessibility and requirements of end user. We will look into each type of API along with their usage in the next section. For example, the APIs which are available for public consumptions (e.g Social media APIs) may not be build same way as APIs available exclusively for an organization.

 

Public APIs

Public APIs, also known as Open APIs are accessible to external developers and are designed for use by third-party developers, partners or the public. They are intended for building applications that interact with external services, platforms or data sources. Examples include social media APIs(e.g Twitter API), payment gateways(e.g PayPal API) and mapping APIs(e.g Google Maps API).

Public APIs often require relatively low authentication and authorization measures . They use mechanism such as API keys, OAuth tokens or similar mechanisms to ensure security and control access.

 

Partner APIs

Partner APIs are also designed for external developers but access to these APIs is restricted to specific partners or collaborators who has relationship with the API owner, typically on a contractual or business basis. They are used when a company wants to provide controlled access to its APIs to trusted partners, affiliated or selected customers via official licenses which ensure the security measures.

Partner APIs are common in scenarios like B2B integrations , affiliated programs and data sharing with strategic partners. Authentication and authorization mechanisms are used to grant access only to authorized partners.

 

Private APIs

Private APIs, also known as Internal APIs  are intended for internal use within an organization . Unlike Public and Partner APIs, they are not intended for internal use within an organization. They are not exposed to external developers or partners for public use. Private APIs are used for connecting internal systems, applications and services in an organization.

They facilitate communication between different parts of organization’s infrastructure, enhancing internal efficiency and automation. Authentication mechanisms are often used for security, but they are primarily intended for internal use and not for external consumption.

 

Composite APIs

Composite APIs are a type of API that aggregates and combines data or functionality from multiple underlying APIs, often abstracting complexity for developers. For example, if you need the data from different sources, you will use composite API. It bundles the multiple request calls and receive one unified response from different servers. They are used to simplify interactions with multiple APIs or services by providing a unified interface.

Composite APIs can be used to aggregate data from various sources, orchestration complex workflows or create higher-level abstractions for developers. For example, when you place an order on Myntra, it might look like a one step process but at the backend it hits multiple APIs each for creating account, adding item in bucket, placing order, payment etc.

 

Summary

We learnt about basic of APIs and usage of all four type of APIs. The concept becomes more interesting when you actually start implementing them. REST API is one of the most usable architectural style used by developers to interact with RESTful Web services.

 

Leave a Comment