Saturday, August 21, 2021

Post#134-API#3 API v/s Web Service

 API v/s Web Service

Web services facilitate communication between two web parties in compliance with communication standards and protocols like Extensible Markup Language (XML), Simple Object Access protocol (SOAP), Web Services Description Language (WSDL) and Universal Description, Discovery and Integration) UDDI and all of these collectively known as Web Services. 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. A Web service is designed to have an interface that is depicted in a machine- executable format usually specified in Web Service Description Language (WSDL- generally is an API). 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. For example, the system calls are invoked using interrupts by the Linux kernel API.

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.

In case of Web applications, the API used is web based. Desktop applications such as spreadsheets and word documents use VBA and COM-based APIs which don’t involve Web service. A server application such as Joomla may use a PHP-based API present within the server which doesn’t require Web service.

A Web service is merely an API wrapped in HTTP. An API doesn’t always need to be web based. 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 .H files in C/C++ programming language, JAR files or RMI in Java, XML over HTTP, JSON over HTTP, etc. The method used by Web service to expose the API is strictly through a network.

Summarizing:

  • Web service is a collection of open source protocols and standards used for exchanging data between systems or applications whereas API is a software interface that allows two applications to interact with each other without any user involvement.
  • Web service is used for REST, SOAP and XML-RPC for communication while API is used for any style of communication.
  • Web service supports only HTTP protocol whereas API supports HTTP/HTTPS protocol.
  • Web service supports XML while API supports XML and JSON.
  • All Web services are APIs but all APIs are not web services.

No comments:

Post a Comment