What is an API?

Spread the love

API stands for application programming interface.

It is an interface through which users or client programs interacts with other systems.

For an example, suppose you want to get the list of all admins in a whatsapp group.

There is a function named as getWhatsAppAdmins(String groupId). It returns a list of all admins. We need to pass the groupId as parameter for which we want the list of admins.

The process of calling the unction from client side is called an API call and through hat API we interact with whatsapp system.

Image Source: Guru99.com

So if you see, the client/user at the rightmost layer calls the API. The client doesn’t know anything about the business logic and the database details. A simple API call should get the job done for the client.

So the question now is where the function/method call should fit in?

So it can be a micro service or a web service.

microservice is a small, independent, application that performs a highly focused service as well as possible. A web service is an internet-based interface that makes the “services” of one application available to applications running on different platforms.

So next question is how to call it?

It can be a GET or a POST call.

In GET, the parameters are concatenated in the Web Service URL itself.

In POST, it is not part of the URL so the limit of POST is huge.

For example,

www.abc.com/whatsappmodule/getWhatsAppAdmins

is a POST call.

www.abc.com/whatsappmodule/getWhatsAppAdmins/1251

becomes a GET call because we pass the whatsapp group id 1251 as well while calling.

here www.abc.com = server address on which application is hosted.

whatsappmodule = name of the application

getWhatsAppAdmins = name of the service

In Spring MVC or REST WS API Call, it is the spring controller or an internal dispatcher which forwards it to the actual service on the basis of the name getWhatsAppAdmins in our case.

Now speaking about the response from the web service, it is either a JSON or an XML response.

Sometimes the o/p is huge which might impact the network usage, so Pagination if done at client side would be good. Like, give me the top 10 admins or something like that etc.

Thanks for reading. Checkout out our other articles as well.