What is RESTful ASP.Net Web API ?

Hello Again...!!!

I am back with another interesting topic called "Web API"

So, in article will get a clear picture of the following 
  • What is Web Site and Web Service
  • What is RESTful service
  • What is API and  Web API
  • What is ASP.Net Web API

Web Site vs Web Service

Today's world is living online. We start our day by taking a selfie and posting it in a social media site. We express our opinions online about the issues/events happening around us.We shop online. We make people happy/irritate online. We make friends/breakup๐Ÿ’” online.We can do Pooja/Archana(not girl's name๐Ÿ‘†) for God  online. Even marriage events are also happening online these days๐Ÿ‘ฌ๐Ÿ‘ฌ

Every time I say online either it references a Web Site or Web Service. It can be a mobile app which consumes Web Service

Basically, a Web Site  is collection of  web pages(GUI) which can be rendered on the browser with the controls(Button, Text box, Date Picker). In whichever language we may write a Web Site, eventually browser renders it into a page with HTML elements, beautifies it with CSS and responds to events through Javascript


Web Service is a module/software which allows communication between server and client by exchanging data  through some protocols . It provides set of functionality which client uses. Unlike a Web Site, there is no GUI where the end user can interact with. 

Example: Whatsapp sends a request to a web service to get all unread messages/unseen photos. Here, requested data will be returned by the service and shown in app in chat window(GUI). User is not triggering any service to get the data, application itself sent a request to Web Service  to pull the data


There are 2 types of Web Services

1. SOAP web service (Simple Object Access Protocol): A service which omits SOAP  protocol where a message/data can be exchanged as an XML document through HTTP. These XML contained with security information to which client/requester this data has to be sent and the actual message/data 

2. RESTful: Services which implements REST(REpresentational State Transfer) architecture. Here data/functionality can be accessed through URI(Uniform Resource Identifiers). 
Data can be exchanged as XML, JSON, Text or PDF etc
Data can be manipulated through fixed set of CRUD(Create, Read, Update and Delete) operations 

API

API(Application Programming Interface) which is having a set of functions and protocols which allows programmers to build and maintain an application requests efficiently. API allows a service to communicate to another services through different protocols(HTTP, TCP,UDP etc)

Web API

Web API is an API(as mentioned above) based web implementation through HTTP protocol
It is a framework to build RESTful Service.Means, it is implemented based on REST principles mentioned above. 
Web API has its own advantages like 
  • Lightweight(efficient with minimal configurations) architecture
  • Easily accessible with any Interface, Language Independent(Once hosted, it can be consumed by any language -JS/C#/Java/Python)
  • Supports communication through HTTP/HTTPS by Request/Response headers
  • Easily execute CRUD operations through HTTP Verbs - GET, POST, PUT and DELETE

ASP.NET Web API

"ASP.NET Web API is a .NET framework which allows us to build RESTful services that can be consumed/called by  Web Application(Browsers), Windows Application(Stand Alone - WinForms), Mobile Application(Android/IOS)"

This works exactly as MVC framework except V. There will not be any view/pages to show the data.
APIs simply process the request from client either it may be getting data from DB Server or saving piece of information into the DB Server

Client can decide in which way the data representation should be.

For example, Microsoft Graph API which allows programmers to access MS Cloud Service resources. So, we can integrate MS services with our own product/software.
This allows us to access User,Groups,Calendar,Mail, Files,Contact information through. So we can integrate/show allowed data in our application.

For instance, if we would like to display the calendar schedule/availability of the user who was signed up with our software by pulling data from actual Office 365 Calendar data, we can easily get this information by sending Client-ID to the API endpoint and do authentication of the user to get Access Tokens. This process is called Authorization and Authentication

We simply register our application with Microsoft portal and get the Client ID and Secret(Authorization). When user wants to see his Office 365 calendar items data on our application, API needs an Access Token which can be given by MS account APIs after successful Authentication of the user

Once we get the Access Token, we can easily consume the resources without user interaction every time. But user need to get authenticated  for the first time to get the tokens.

So, this way communication between the services and clients becomes easy and allows programmers to give a better experience for the user or other services

This is more of theory, we will jump into the actual coding part of the Web API in further articles

Thanks for your patience...!!!





Comments

Post a Comment

Popular posts from this blog

Dependency Injection in C Sharp(C#)

What is .Net, ASP.Net and MVC.Net ?

ASP.NET Web API with C# - Implementing GET method and accessing in C#,JQuery