Introduction
API stands for Application Programming Interface. When we use an application, it connects to the Internet and sends information to a server. The server retrieves the data, interprets it, takes the appropriate actions, and sends it back to our phone. The software then analyses the data and displays the information you requested legibly. All of this happens via application programming interface or API.
In the diagram below, we can understand how an API works as an intermediate software agent and allows two or more applications to interact with each other.
Let us try to understand API with a real-life example.
Suppose you are at a restaurant and you ordered a dish. Now the dish is being prepared in the kitchen, but you are waiting at the table for the dish. There has to be an agent to bring the food from the kitchen to the table. In this case, that agent is the waiter. Similarly, API plays the role of a waiter in programming, who serves information between the server and the client.
Now, let’s get to know about web API’s.
Also Read, Javascript hasOwnProperty
What is a Web API?
As the name implies, a web API can be accessed using the HTTP protocol over the Internet. It's a framework for creating and developing RESTFUL HTTP services.
Different technologies, such as Java and ASP.NET, can be used to construct the web API. A web server or a web browser can both use the this API.
Web API is, at its core, a notion in web development. It only covers the client-side of a web application and excludes information about a web server or a web browser.
Need of a Web API
When the user wants to access an application from various devices like android phone, a browser or some Google devices, etc. In this case, Web API can be useful.
The reason being, when different devices request to Web API, it responds in a common JSON format. Most of the devices are able to understand JSON output.
Refer to the diagram below to understand the Web API Architecture.
In a nutshell, we can say that Web API services are utilized when an application is to be used on a distributed system and deliver services to various devices such as laptops, mobile phones, etc.