Monday 15 March 2021

PArt 1 : Web API Introduction

In this article I will discuss on what is web API and implementation of web API in Asp.Net Core 3.1.
Let’s understand first What is an API?
API (application program interface) again piece of code, protocol and subroutine for building software’s. In another term API is already developed software or tool and client needs to consume it. Now Web API is the API over the web, and it can be used with the help of HTTP protocol. Web API is concept and supported by different technologies .Net, Python, Java etc.

Why Web API is in demand today? Let’s understand below real time example.
Suppose cell phone charger with and without USB Port. Shown in below screen.
Above charger is normal charger without USB. To charge mobile battery I must need to use electric socket only.
Charger with USB connection.
Above charger with USB cable can be used not only with electric socket but multiple devices like laptop, desktop, car, etc. Same USB cable is used for charging mobile, exchanging data and it can be reused in multiple devices. One USB cable communicating with multiple devices. Same concept applicable with Web API, WEB API can be reused in multiple technologies like for desktop application, web applications, browsers, mobiles, etc.

WEB API provides set of instruction which allows clients to consume services provided by an API. Implementation of API is hidden from clients, but API provide enough information to client for accessing information from Web API.

  In this series I will show you WEB API with Rest (Representational State Transfer). Rest is an architectural style with set of principles used for building WEB API.
WEB API needs to follow condition or set of rules provided by REST to become Restful API. Rest is nothing but guide or set of rules to develop an API.

For Web API to be restful, API should follow below points.
1.Separation of Client and Server: Follow client-server architecture, implementation of server and client hidden from both. Client can be anyone capable of communicating via HTTP protocol.
2.Uniform Interface: Uniform interface is nothing but an idea of transmitting information in standardized way.
3.Stateless Protocol: As HTTP is stateless protocol, each request should contain appropriate information to communicate with server and processing further operation on server side. Both client and server not aware about current state. Request should contain all information to achieve current task.
4.Cache: Client can cache frequently required resources at client side and load information next time from cache.
5.Code On Demand: An option of sending back piece of code(javascript) to client.

1 Comments:

At 16 March 2021 at 02:36 , Blogger Girish Pawar said...

Awesome...helpful for the learning perspective.

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home