what is web services and api code example

Example 1: what is web api

// The ASP.NET Web API is an extensible framework for building HTTP based services.
// It works more or less the same way as ASP.NET MVC web application except that it sends data as a response instead of html view.

Example 2: API vs Web Services

1. All Web services are APIs but all APIs are not Web services.
2. Web services might not perform all the operations that an API
would perform.
3. A Web service uses only three styles of use: SOAP, REST and
XML-RPC for communication whereas API may use any style for
communication.
4. A Web service always needs a network for its operation whereas
an API doesn’t need a network for its operation.
5. An API facilitates interfacing directly with an application whereas
a Web service is a required a path.