The basics of API and Web API

Foridul Islam
5 min readAug 19, 2022

--

A guide to knowing the details about API

Application Programming Interface commonly known as API is a mechanism that enables two software components to communicate with each other using a set of definitions and protocols.

Source: https://testautomationresources.com/api-testing/differences-web-services-api/

In the context of APIs, the word Application refers to any software with a distinct function. The interface can be thought of as a contract of service between two applications. This contract defines how the two communicate with each other using requests and responses.

Working process of API

Suppose we have two software, first one is User management software and another one is Orders management software. They want to communicate with each other. If we want to know the orders of a specific user, the order software exposes an API that the user management software uses and knows the orders of a specific user. The User management software can call the API exposed by the Order management software and get the orders of the user.

Types of API

According to the release policies, the API can be classified into 3 types.

  1. Private API: These are internal to an enterprise and only used for connecting systems and data within the business.
  2. Public or External API: These are open to the public and may be used by anyone. There may or not be some authorization and cost associated with these types of APIs.
  3. Partner API: These are only accessible by authorized external developers to aid business-to-business partnerships.

But According to the use of API, it can the 4 types,

  1. Operating System API: It defines how applications use the resources and services of operating systems
  2. Library API: It defines the way of application communicates with some software component, typically a library. For example, Java API.
  3. Remote API: It defines standards of interaction for applications running on different machines
  4. Web API: These APIs mainly deliver requests from web applications and responses from servers using Hypertext Transfer Protocol (HTTP).

Importance of API

API architecture is usually explained in terms of client and server. The application sending the request is called the client, and the application sending the response is called the server.

The API can be used by the client and it extends the app's reach.

API is important because it is easy to incorporate and reduce the software development cost. Also, API provides a secure communication getaway for different software applications to interact and exchange data.

Modern applications are built for both web and mobile and the mobile apps must have an API on the server to communicate with it. Also, by exposing your API, you can your data from another application and sometimes you can charge for the access of data.

Web API

Web API is a software-to-software interface that provides communication or interaction between software applications and exchanges data among each other. Basically, It’s an interface between a web server and a web browser.

Characteristics of Web API

There have some characteristics of web API as follows.

  1. Not rely on a specific platform
  2. Use standard protocol usually HTTP
  3. Request/Response based

Types of Web API

Web API can be differentiated on following

  • Request Format(JSON/XML/text)
  • Request Contents
  • Response Format(JSON/XML/text)
  • Response Contents

Considering the above criteria, web API can be the following types.

  1. SOAP
  2. REST
  3. GraphQL
  4. gRPC

SOAP

Simple Objects Access Protocol known as SOAP is a web communication protocol designed for Microsft in 1998. SOAP web API supports XML format which is a very flexible text format. XML defines a set of rules for the security of documents. Client and server exchange messages using XML.

Currently, this is a less flexible API that was more popular in the past.

REST

REST stands for Representational State Transfer. REST defines a set of functions like GET, POST, DELETE, etc. that clients can use to access server data. Clients and servers exchange data using HTTP. It is based on URL and JSON.

GraphQL

GraphQL is a query language that was developed specifically for APIs. It was internally developed in 2012 by facebook and released publicly in 2015. It is designed to make APIs fast, flexible, and developer-friendly

The biggest advantage of GraphQL is it enables very flexible querying, updating, and subscribing to data changes.

In contrast to REST, GraphQL allows you to specify exactly which fields you want to get back and in addition, you can specify what parameters you want to use in the query itself. Similar to REST, based on JSON in and out.

gRPC

gRPC was developed by google in 2015 and it is based on HTTP/2. The most important thing about HTTP/2 is it allows streaming means instead of request and response, we can implement a duplex. Like, the server can send messages to the client. It supports bi-directional and streaming messaging.

In contrast to GraphQl, the performance of gRPC is great because it is based on HTTP/2 which is a very performant protocol. But currently, it is not widely used yet because HTTP/2 is not very popular at this time.

Summary

In this article, we discussed the very basics of API and web API. Each type of API has a details and long discussion. One thing that needs to be remembered is that, as API and web API are a great way to communicate with one application to another, it needs to be designed well and carefully. Because it affects the performance of the system. Next, we will discuss the REST API.

Thanks for reading!

--

--

Foridul Islam
Foridul Islam

Written by Foridul Islam

Sr. Software Engineer at SELISE Digital Platforms

No responses yet