Roy Fielding defined REST
("Representational state transfer")
as the style of architecture used in (the already-existing) HTTP.
Similar APIs are called "REST-ful" APIs.
- RESTful systems
typically communicate over HTTP
with the basic HTTP methods
(GET, POST, PUT, etc.)
Properties of RESTful systems
of Roy Fielding's PhD.
Properties of RESTful systems:
- Client-server model.
Data storage on server only.
UI on client only.
HTTP model is stateless. One URL request has no relation to later URL request.
There are ways to keep state on Web
Built on top of a stateless protocol.
The HTTP model aims to reduce duplicate requests by caching data on client.
It builds in a model where responses can be defined as cachable or not.
- Uniform interface to resources:
- Resource address passed in request.
Web uses URLs as universal address of resources (same address for each client to use).
- Response contains description of resource type.
("Hypermedia as the Engine of Application State")
Responses contain addresses for further resources.
(Page contains links to more pages.)
- Layered system.
Intermediate servers can be introduced between client and server. Can do caching, security.
on the Web.
He adds as optional:
Client does not need to install applications in advance. Client stays simple.
Server sends code to client to implement functionality at run-time.
Read-write RESTful systems
may be primarily read-write systems
The normal Web
is mixed (large parts read-only,
other parts read-write).
Say we have collections of resources,
and an individual resource is a member of a collection,
in a read-write system.
We might define our RESTful API methods as follows.
| Method call
|| What it does
|| Permanent effect
| GET (collection URI)
|| List URIs of members of collection
Readable web directories
| PUT (collection URI)
|| Replace entire collection with uploaded data
| POST (collection URI)
|| Add new element to collection
| DELETE (collection URI)
|| Delete entire collection
| GET (member URI)
|| Client retrieves copy of member of collection
| PUT (member URI)
|| Replace member with uploaded data
| DELETE (member URI)
|| Delete member