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 ?
|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 methods||Wcf 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.
- Resource URI : Every resource on the web is identified by unique URI.
- Http Method: the methods which we use have standard verbs like Get,Put,Post,delete
- Payload: What kind of representation we use by using media type formatter
Resource naming Guideline:
- 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
To build an API we use ASP .Net core version 3+.
Asp.Net core in big picture
- It is a framework which we used for creating modern internet based connected applications.
- Its modular version of .Net framework
- It is portable across all the platform
- .Net core will run on mac,windows and linux also
- 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, 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.