What is REST API ?
It seems to be a complex question but answer is simple. REST or RESTFUL API is an application programming interface over WEB that follows the REST architectural style and facilitates interaction with RESTful web services. The full form of REST is representational state transfer.
Above definition also contains the phrase ‘Web Service‘. Now let me explain in simple way.
What is a web service ?
A web service is anything which provides client to server or vice versa communication. It is a software that allows transactions between digital nodes. For example when you open google.com on your laptop you get a webpage on your screen. The request goes from your browser to internet and in response you get a google search web page. So this communication is sent to the web service residing on google servers which in return sends the google web page on your screen.
A web service is nothing but a group of protocols, codes and internet standards which facilitates communication between 2 nodes. Now ‘node’ can be a server a client or an application.
There are 2 types of web services. REST and SOAP.
Please note that software around the world are designed using any programming languages like JAVA, C++, .NET etc. So if an application is designed in JAVA and it wants to communicate with another application residing on a different server which supports .NET then how to make them exchange data or communicate.
To facilitate such kind of communications ‘web services’ come into role. Web service can be called as a mediator between 2 applications or 2 servers or a client and a server. Precisely Web services are categorically designed to be used as a web page request and send the response to user. Response is nothing but the data which user had requested via browser.
SOAP – Web service type SOAP is nothing but a protocol which was created long before REST was brought to the world. The critical reason for creating SOAP was to make sure that applications designed on different programming languages could securely communicate.
REST – Web Service REST was was created particularly for working with media files, text files and any other objects residing on servers. A web service that is based on the principles of REST is also called a RESTful web service. RESTful uses HTTP methods like GET, POST, PUT and DELETE for working with the components.
What is an API ?
The API stands for Application Programming Interface. It is a software interface that allows two applications/servers to communicate with each other without human intervention.
APIs facilitates a service or product to interact and exchange data with other services and products without them having to know that how they’re implemented or deployed, because API follow the encapsulation paradigm.
API is also a type of web service which uses REST architecture, thus API supports conventional CRUD (Create Read Update Delete) operations as includes all HTTP Methods which are GET, POST, PUT, and DELETE. API can run in background without the need for an interface.
NOTE : All APIs are not Web Services.
Difference between Web Service and API.
|Web service is a subset of API which means All web services are APIs.||API is a superset of Web service which means All APIs are not web services.|
|Web service supports XML.||APIs support XML and JSON.|
|Web service uses SOAP protocol thus it is heavy weight architecture.||API uses REST thus has a light-weight architecture.|
|Web service understands XML requests.||API understands JSON or XML requests.|
Keep looking into the space. This is a theory blog over Web services vs API. My next blogs would be working JAVA codes to explain APIs.
Happy Coding 🙂