REST vs. CRUD
--
With diagrams: Commands, architecture and networking.
Prerequisites:
- None
Terminology
CRUD: The four basic functions of persistent storage; create, read, update, and delete
REST (REpresentational State Transfer): architectural style for providing standards between computer systems
REST
REST
is a defining set of principles for developing an API. Uses HTTP protocols like GET, PUT, POST and DELETE to link resources to actions within a client-server relationship. The principles of RESTful architectures serve to create an application as a lighter weight alternative to SOAP. APIs may be web-based or designed for specific platforms such as Android or iOS, and a REST
API makes it easy to implement other interfaces or applications over time which can turn an initial project from a single application into a platform.
The diagram:
The client may be a web browser requesting weather information in Washington i.e “washington” and receives a JSON string of [“16”]. REST
API’s often use result codes (200 = OK; for example)
The six guiding constraints of REST
The client-server mandate
This shows there is a nature of separation between client and server. Services have multiple capabilities and listen for requests which are made by the consumer and accepted or rejected by the server.
Statelessness
Mandates the kinds of commands offered between the client and the server, which is initiated by the request. The request contains all the information necessary for the server to respond.
Cache
Server responses are either cacheable or not. A request can be cached by the consumer in an attempt to avoid re-submitting the same request twice.
Interface or uniform contract
RESTful architecture defines a Uniform Contract. This prohibits the use of multiple, self-contained interfaces within an API.