What Is Web API?

Post date:

Author:

Category:

Web API – Definition:

API stands for Application Programming Interface. Web API helps the developers to connect two different applications. API provides a mean for interfacing the applications to one another. It consists of a set of subroutines, protocols, and tools for building and maintaining the applications. The common goal of all APIs is to speed up the process of development by using different applications which are interfaced together. Several APIs are present for many systems like operating systems, libraries and the web.

History Of Web APIs:

Web APIs traces its origin from the root UNIX itself on how different applications or processes use to communicate with each other. The major contribution to Web APIs was made by Sun Microsystems Solaris. The system through which different processes sends and receives message is possible using the IPC (Inter-Process Communication). Further, Sun Microsystems used the way how the network socket operates to develop Remote Procedure Calls (RPC) which is a way to communicate with the processes remotely. It became popular as any application were able to send messages to a remote procedure which replied to the query. Then came the RFC protocol which was published in 1995. Sun changed the license to standard 3-clause BSD which made it available for everyone to use without any charges. RFC protocol had certain limitations regarding the parameter passing. Then came the SOA (Service-oriented architecture) which overcame the limitations of RFC protocol.

In 1989, World Wide Web (WWW) was introduced by Tim Bernes-Lee. Initially, the web pages consisted of simple interconnected pages. Over time the WWW was developed which provided an interface with different applications.

Different Types Of Web APIs:

APIs which works at the operating system level helps the applications to communicate with the underlying layers easily by following a set of protocols. POSIX (Portable Operating System Interface) is an excellent example of such API which allows the applications to work on different OS when compiled for a single OS. APIs are used to define the way software libraries behave. Applications are allowed to communicate with the software libraries by following a set of rules which are specified by the API. Thus the programmer can reuse the applications which were built before and interface them with the new software being developed.

ASP .NET Web API:

ASP .NET Web API is a framework that helps in building HTTP services which interact with browsers and mobile applications. It is also an ideal platform for building RESTful applications with the .NET framework. It works in a similar way ASP.NET MVC works with an exception that it sends data as responses rather than HTML view. It is a Web Service but supports only HTTP Protocol. ASP.NET Web API is built on top of ASP.NET and supports the request/response pipeline.

For building a Web API using ASP .NET the basic need is Visual Studio. Follow the steps below for creating Web APIs:

  1. Open the Visual Studio Application. Create a new project by File->New->Project from the menu option.
  2. From the left panel, select Templates->Visual C#->Web.
  3. Select ASP .NET Web Application available in the middle panel.
  4. Enter the project name in the Name Field and click OK to continue.
  5. Select the initial template to start with. For keeping it simple and easy, select the Empty Template.
  6. Check the Web API checkbox and click on OK.
  7. A basic MVC project with minimal data will be created.
  8. From the Solution Explorer window right click on the Model folder. Select Add->Class to add a model.
  9. Select the class from the middle panel and give it a name. It is stored with .cs extension (Here we will create employee.cs for demo).
  10. Define the properties of the class using the code given below: System.Collections.Generic;using System.Linq;

    using System.Web;

    namespace WebAPIDemo.Models {

    public class Employee{

    public int ID { get; set; }

    public string Name { get; set; }

    public DateTime JoiningDate { get; set; }

    public int Age { get; set; }

    }

    }

  11. Add a controller by selecting Controller folder in the Solution Explorer. Select Add->Controller.
  12. Select Web API2 Controller. Define the Controller with some default actions.
  13. Run the application and press Enter at the end of the URL.
  14. Specify the URL http://localhost:63457/api/employees/1 and you will get the output as below:

STAY CONNECTED

15,753FansLike
567FollowersFollow
1,554FollowersFollow
12,297SubscribersSubscribe

INSTAGRAM

Shortcuts to Best Scholarship Essay Samples Only the Experts Know

Shortcuts to Best Scholarship Essay Samples Only the Experts Know The Honest to Goodness Truth on Best Scholarship Essay Samples Both...

Help Me Write My College Essay

Written exactly to specification, would advocate this writer to anybody.If you find oneself perpetually bothered about your assignment with the believed, “Can any...

Key Pieces of Good Essay Writing Service

Key Pieces of Good Essay Writing Service The 30-Second Trick for Good Essay Writing Service When you get essay from us,...