REST Web Services
REST stands for REpresentational State Transfer. It was created in 2000 by Roy Fielding in UC, Irvine.
- It is an architectural style, and an approach to communications that is often used in the development of Web services.
- It’s an arrangement of functions on which the testers performs requests and receive responses. In REST API communications between clients and servers are made through HTTP protocol.
- REST also allows communication between one computer to computer other over a network.
- For sending and receiving messages REST involves HTTP methods which does not require a strict message definition.
- REST follows the ideology of the Open Web.
- It is easy to implement and maintain as compared to SOAP.
- It clearly separates client and server implementations
- REST Information can be stored by the client to prevent multiple calls.
- REST describes a set of architectural principles by which data can be transmitted over a standardized interface using HTTP.
- REST allows better support for browser clients due to it’s support for JSON.
- REST does not contains additional messaging layer.
- It focuses on design rules for creating stateless services.
REST Workflow :
It’s four principles can explain the success and the scalability of the HTTP protocol implementing them
1. Resource identification through URI
2. It provides uniform Interface for all resources:
GET (Query the state, idempotent, can be cached)
POST (Update a resource or create child resource)
PUT (Transfer the state on existing/new resource)
DELETE (Delete a resource)
3. It has “Self-Descriptive” Message representations
4. Hyperlinks to define relationships between resources and valid state transitions of the service interaction
HTTP Verbs describe the type of operation:
Fig. : HTTP actions
- GET: It is used to retrieve a resource
- POST: It creates a new resource
- PUT: It updates an existing resource
- DELETE: It deletes an existing resource
Workflow of HTTP Verbs :
When to use REST:
- When clients and server both operates on Web Environment, we should use REST.
- When information about the object need not to be communicated to the client.
Advantages of REST API :
- Communication is not controlled by a single entity.
- clearly separates client and server implementations.
- Information can be stored by the client to prevent multiple calls.
- It returns data in multiple formats(JSON, XML)
- It is easy to implement and maintain.
Dis-Advantages of REST API :
- It works on the top of HTTP protocol.
- It is hard to enforce authorization.
- It has stateless existence.
- It leverages a layered system and uniform interface
- Security is on top of it.