All of us software developers come across one word almost daily-REST
Let’s try to understand what it actually is and what are other options if not REST…..
1. A REST API (also known as RESTful API) API that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services. REST stands for representational state transfer.
2. REST is a set of architectural constraints, not a protocol or a standard. API developers can implement REST in a variety of ways.
When a client request is made via a RESTful API, it transfers a representation of the state of the resource to the requester or endpoint.
3. The resources transferred in REST can be done in various formats: JSON (Javascript Object Notation), HTML, XLT, Python, PHP, or plain text.
4. These representations for resources, or collections of resources, are made discoverable via a method known as hypermedia. Hypermedia is fundamental to REST and is essentially just the concept of providing links to other resources.
5. In order for an API to be considered RESTful, it has to conform to these criteria: 1) A client-server architecture with requests managed through HTTP. 2) Stateless client-server communication, meaning no client information is stored between GET requests and each request is separate and unconnected.3) A layered system that organizes each type of server component into hierarchies, invisible to the client.
6. Before REST, most of the web APIs were of RPC format. RPC stands for remote procedural calls. All mainstream modern programming languages that are used to produce and consume APIs use procedures as their central organizing construct, so, procedures have also been the dominant model for designing and implementing distributed APIs for decades, in the form of Remote Procedure Calls (RPC).
7. An API is built by defining public methods; then, the methods are called with arguments. RPC is just a bunch of functions, but in the context of an HTTP API, that entails putting the method in the URL and the arguments in the query string or body(in some format like XML).
8. One major standard for RPC API is SOAP(Simple Object Access Protocol). Since SOAP is a protocol, it follows a strict standard to allow communication between the client and server. SOAP uses only XML for exchanging information.
9. If using SOAP, clients need to have a lot of information about web service which is transferred using a WSDL file. This file has the required information on what the web service does in addition to the location of the web service(like the complete function defined in XML). Hence, it required more bandwidth
10. RPC formats are still used in various cases. Some use-cases do require actions/procedures to be executed and hence RPC is better in those scenarios. Also, SOAP offers more security and hence is used in Bank Account/Credit Card transactions.