What is Web API?

Long form of API is Application Programming Interface and it means Web Api is a kind of interface which allows the consumer to access the set of functions which the consumer is allowed to consume or main purpose of the API is to provide data.

We can access the Web API over HTTP protocol. Main thing is that it is not technology, it is a concept and we can create api in several technologies like Java,.Net and .Net core.

In this tutorial we can create an API in Asp.Net Core.

Asp.Net Core Web API  is a framework for building HTTP based  services which can access different devices or applications like Windows, Mobile and Web. It is like Web Service or we can say WCF service but it only supports HTTP protocol.

In this tutorials we will use Visual studio 2019 Community edition https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=16

You can download this from this link.

To check api calls and results we can use Postman for that. To download postman you can use below link https://www.postman.com/downloads/

What is the difference between ASP.NET Core Web API vs WCF ?

Web APIWCF
It is an Open source  framework.It comes with .NET framework
It Supports only HTTP protocol.It supports different protocols like  HTTP, TCP, UDP and custom transport protocol.
Here we Maps http verbs to methodsWcf Uses attributes based programming model.
Web API Uses routing and controller concept similar to ASP.NET MVC.WCF Uses Service, Operation and Data contracts.
Web API can be configured using HttpConfiguration class but not in web.config.WCF Uses web.config and attributes to configure a service.
Web API is Ideal for building RESTful services.WCF Supports RESTful services but with limitations.

Web API Structuring Outer Facing Contract?

When we talk about outer facing contracts we have 3 main things.

  1. Resource URI : Every resource on the web is identified by unique URI.
  2. Http Method: the methods which we use have standard verbs like Get,Put,Post,delete
  3. Payload: What kind of representation we use by using media type formatter

Resource naming Guideline:

  1. URI is must be Noun means it is thing and not an action

For example if our URI is api/getstudents it is action but by convention we use

Get api/students – it is noun 

By using nouns it describes resources. Filters, sorting aren’t resources ex. api/students/orderby/name this is wrong. Best way to do that is 

api/students?orderby=name 

To build an API we use ASP .Net core version 3+.

Asp.Net core in big picture

  1. It is a framework which we used for creating modern internet based connected applications.
  2. Its modular version of .Net framework
  3. It is portable across all the platform
  4. .Net core will run on mac,windows and linux also
  5. Increase performance

To download .Net core framework use below site https://dotnet.microsoft.com/download

Also for database section we use Mysql community edition use below link to download what you required for development https://www.mysql.com/downloads/

Sagar Jaybhay

Sagar Jaybhay, from Maharashtra, India, is currently a Senior Software Developer. He has continuously grown in the roles that he has held in the more than seven years he has been with this company. Sagar Jaybhay is an excellent team member and prides himself on his work contributions to his team and company as a whole.

Leave a Reply

Your email address will not be published. Required fields are marked *