API and Web Service both act as means of communication, but there are specific differences between them.
What is API?
Currently, API is more and more widely applied in the field of information technology.
API (Application Programming Interface) is known as the intermediary mechanism, consisting of a set of methods that allow two components of each different program to communicate and connect.
With APIs, data exchange between applications can be made simpler and faster.
What is Web Service?
Web Service can be compared as a “bridge”, including protocols and standards used in linking and exchanging data between software - applications built from many different programming languages.
This is simply an API wrapped in HTTP - the protocol has quite a wide range of applications at hypertext transport.
It has a design in which the interface must be described in a computer-processable format.
SOAP, REST and XML-RPC are the three main standards that Web Service often use as a means of communication.
According to comments from experts, Web Service is a new breakthrough in the software development industry.
To summarize, Web Service:
- A method of communication between two devices over a network.
- Is a communication application component.
- A set of protocols or standards for exchanging information between two different systems.
Difference between API and Web Service
API | WEB SERVICE |
All APIs are not Web Services. | All Web Services are APIs. |
Any standard can be selected as a means of communication and interaction between applications. | Only use 03 main standards are SOAP, REST and XML-RPC in the communication process. |
The response is returned in XML, JSON or any other format. | Support for XML format. |
Light weight architecture. | Heavy weight architecture. |
Does not require a network connection at all times. | Requires a network connection to work. |
Support for many different protocols such as HTTP, URL Request, Response Headers, Content Format... | Only HTTP protocol is supported. |
Besides, Web Service also cannot perform all the tasks that a complete API is capable of.