The term representational state transfer was defined in 2000 by Roy Fielding in chapter 5 of his doctoral dissertation Representational State Transfer (REST). REST is nothing more than the description Fielding defined in his dissertation. There is and will be no RFC or a specification for it by an authoritative organization. REST is mostly based on HTTP but can be based on other protocols. Fielding is also one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification versions 1.0 and 1.1.
A RESTful web service (or RESTful API) is a web service implemented using HTTP and the principles of REST with the following four aspects:
- base URI for the web service
- media type of the data, e.g. JSON or XML
- set of supported operations as HTTP methods (GET, PUT, POST, DELETE, etc)
- hypertext driven API
REST architecture describes the following six constraints:
- separation of concerns between client and server, e.g. client is responsible for UI and server for data storage.
- stateless, each request must include all information to service the request
- cacheable client to prevent unnecessary client-server messaging
- code on demand (optional), server should be able to extent client functionality by including client-side code
- uniform interface, four guiding principles:
- identification of resources, e.g. using a URI
- client must have enough information to be able to manipulate the resource representation
- self-descriptive messages
- HATEOAS, Hypermedia as the engine of application state
REST vs SOAP
REST | SOAP | |
typing | weak | strong |
requires message header | no | yes |
requires XML parsing | no | yes |
error handling | HTTP | user defined |
asynchronous support | no | yes |
stateful | no | yes |