Web Services

Kenneth M. Anderson <kena@cs.colorado.edu>

Lecture 15: REST

Agenda

REST

REST Design Principles

  1. Stateless Client/Server Protocol: Each message contains all the information needed by a receiver to understand and/or process it. This constraint attempts to “keep things simple” and avoid needless complexity.
  2. A set of uniquely addressable resources enabled by a universal syntax for resource identification; “Everything is a Resource” in a RESTful system
  3. A set of well-defined operations that can be applied to all resources; In the context of HTTP, the primary methods are POST, GET, PUT, and DELETE, similar (but not exactly) to the database world's notion of CRUD (Create, Read, Update, Delete).
  4. The use of hypermedia both for application information and state transitions. Resources are typically stored in a structured data format that supports hypermedia links, such as HTML or XML

REST Operations

Method Meaning Idempotent?
GET Retrieve a copy of a Resource YES
DELETE Remove a Resource YES
POST Create NO
PUT Create or Update a Resource YES

REST vs. RPC

<user>
    <name>Jane User</name>
    <gender>female</gender>
    <location href="http://www.example.org/locations/us/ny/new_york_city">
        New York City, NY, US</location>
</user>
            

Amazon S3 REST-based API

Readings for Next Time

Class Project