Traversing REST Web services
The technological term REST stands for Representational State transfer.
It can be defined as a framework which utilizes HTTP web protocol as a means of communication between client and server independent of any platform or technology built around the transfer of resources .
World Wide web (WWW) can be represented as a best example of REST architecture.
In context of REST Web can defined as distributed system where resources are linked to each other and communicate with each other through exchange of resource state representation.
REST similar to HTTP follows principle of stateless nature which means that each request is independent of each other i.e does not retain information or status of previous requests.
Components are major constituents which together build a complete system.
REST has three major components.
Resources constitute base of REST web services.
While implementation of REST based systems initially we need to identify resources of system and their connections with other resources.
Resources are represented through URL.
Following is an example of resource representation as a part of URL
In above mentioned example v1 can be described as a API version and categories acts as a resource
The term verb describes an action.
Every resource in REST based system has action associated to it.
In REST web services basic HTTP methods bind actions to resources which correspond to create, read, update, and delete (or CRUD) operations respectively.
Basic HTTP actions are
- GET: It is utilized to retrieve resource.
- POST:It is utilized to create a new resource.
- PUT: It is utilized to modify a resource.
- DELETE: It is utilized to delete a resource.
- OPTIONS: It is utilized to determine the options and/or requirements associated with a resource, or the capabilities of a server .Its basic usage is to send CORS request is sent prior to actual request to ensure the safety of actual request
Below mentioned are examples of verbs usage in REST Web services.
- GET http://www.mysite.com/api/v1/categories
- GET http://www.mysite.com/api/v1/categories/123/products
- POST http://www.mysite.com/api/v1/categories
- PUT http://www.mysite.com/api/v1/categories/123
- DELETE http://www.myquote>site.com/api/v1/categories/123
Representation is final presentation of resources to client after executing actions on resources.
REST offers support for all formats to represent resources.
Amidst all formats JSON and XML are most widely used formats for resource representation.
Representation of resource is accomplished through usage of HTTP headers.
The Accept header informs the server what your client wants in the response. The Content-Type header tells the server what the client sends in the request.
Thus REST offers better advantage of flexibility.
From above article we can conclude that benefits of HTTP protocol and web platform can be availed through REST web services.
Traversing REST Web services
Contact for PHP Mysql, Codeigniter, Laravel, symfony, NodeJS, AngularJS, ReactJS training in mumbai.
Weekend Classes available.
Call me on 9022349606.