Advantages of REST

1. Overview

REST is an acronym for REpresentational State Transfer.
REST is a lightweight alternative to mechanisms like RPC (Remote Procedure Calls) and Web Services (SOAP, WSDL, etc). REST is an architecture style for designing networked (distributed) applications. The idea is that rather than using complex mechanisms such as CORBA, RPC, or SOAP to connect between machines, simple HTTP is used to make calls between machines. RESTful applications use HTTP requests to post data (create and/or update), read data (e.g., make queries), and delete data. Thus, REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations.

Web applications are not used only by browser clients. Programmatic clients can connect using HTTP

(e.g., mobile applications and basically any application that was developed to be able to request and
receive data using HTTP as a communication protocol).

A RESTful architecture is a stateless client-server architecture, so the system is disconnected (loosely coupled).


HTTP verbs are used as actions to execute on the resources (GET,PUT,PATCH, POST, DELETE, HEAD, OPTIONS). The main REST HTTP methods with their actions:

GET

Reads a resource, does not change it. Therefore can be considered safe. Reading the same resource always returns the same result. Therefore can be considered idempotent.

POST 

Used to create a new resource. Neither safe nor idempotent. Two identical POST requests will result in two identical resources being created or errors at application level.

PUT 

Most often used for update capabilities. It is not safe, since it modifies the state on the server, but is idempotent (unless subsequent calls of the same PUT request increments a counter within the resource, for example).

DELETE 

Used to delete resources. Not safe, but can be considered idempotent. Because requests to delete a resource that no longer exists will always return a 404 (not found).
Read more about REST on Overview of REST

2. Advantages of REST

  • REST is simple.
  • REST is widely supported.
  • Resources can be represented in a wide variety of data formats (JSON, XML, etc.)
  • You can make good use of HTTP cache and proxy server to help you handle high load and improve performance.
  • It reduces client/server coupling.
  • Browsers can interpret representations.
  • Javascript can use representations.
  • A rest service can be consumed by applications written in different languages.
  • It makes it easy for new clients to use a RESTful application, even if the application was not designed specifically for them.
  • Because of statelessness of REST systems, multiple servers can be behind a load balancer and provide services transparently, which means increased scalability.
  • Because of the uniform interface, little or no documentation of the resources and basic operations API is necessary.
  • Using REST does not imply specific libraries at the client level in order to communicate with the server. With REST, all that is needed is a network connection.

3. Conclusion

In this post, we learned what is REST and its advantages like REST Resources can be represented in a wide variety of data formats (JSON, XML, etc.), it's simplicity, lightweight, reduces client/server coupling, statelessness, cacheable etc.

REST services can be secured, but since the interaction between client and server is stateless, credentials have to be embedded in every request header.

4. Related Posts

Comments