Difference Between API and Web Service

API and Web service serve as a means of communication. The only difference is that a Web service facilitates interaction between two machines over a network. An API acts as an interface between two different applications so that they can communicate with each other. An API is a method by which the third-party vendors can write programs that interface easily with other programs.Typically, “HTTP” is the most commonly used protocol for communication. Web service also uses SOAP, REST, and XML-RPC as a means of communication. API may use any means of communication to initiate interaction between applications.

An API exactly defines the methods for one software program to interact with the other. When this action involves sending data over a network, Web services come into the picture. An API generally involves calling functions from within a software program.
merely an API wrapped in HTTP. An API doesn't always need to be web based. An API consists of a complete set of rules and specifications for a software program to follow in order to facilitate interaction. A Web service might not contain a complete set of specifications and sometimes might not be able to perform all the tasks that may be possible from a complete API.

The APIs can be exposed in a number of ways which include: COM objects, DLL and JAR files or RMI in Java,
  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.

Enjoy .Net