R E ST W I T H A M A Z O N ’ S S 3
The Representational State Transfer (REST) architectural style is a popular distributed systems
design pattern based on the architectural pattern of the World Wide Web—specifically, the HTTP
protocol. REST is both a set of principles for building any distributed system and also a specific set
of implementation choices when using HTTP.
The REST architecture is considered to be the guiding style used for the HTTP protocol. The term
REST, as well as a codification of the principles it espouses, was first published in Roy T. Fielding’s
PH.D thesis (http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm).
At the core of the REST set of patterns is the idea of a Resource, the resource’s URI, the resource’s
Representation, and a standard, codified set of operations you can have performed on the
resource by a distributed system’s actor:
Operation
Read
Delete
Create
Description
Access a resource without
causing any side effects.
Delete a resource.
Create a new resource.
Update
Modify a resource’s value.
HTTP Method
GET
DELETE
PUT (and
sometimes POST)
POST (and
sometimes PUT)
Notice that the access pattern for a resource is the familiar CRUD interface. HTTP’s most popular
verbs map very well to this pattern.
Note: There is some debate, and usage in practice varies, as to PUT and POST for Create and Update.
It is most practical to consider that either verb may be used for either operation.)
A resource is an abstract concept. Usually it is a document or a piece of data. Resources have a
name: a URI (Uniform Resource Indicator). For instance, the document at the root of the web server
amazon.com is http://www.amazon.com/index.html. In many cases, a resource is really a collection
of data items that can be viewed and processed in a variety of ways. For instance, the HTML
resource returned by http://www.amazon.com/index.html may be full XHTML when a
contemporary browser accesses it. But when a mobile device accesses that URI, it receives a
different representation, such as a minimalist HTML for mobile devices. In HTTP, this is handled
through the accept-header.
For instance, to access the resource at http://www.amazon.com/myresource.jpg, you send a GET
request, using HTTP:
GET /myresource.jpg HTTP/1.1
Host: www.amazon.com
Page 1 of 3