84

Lately I have become interested in familiarizing myself with REST. I tried reading wiki entry on REST, but it was of no help. I would really appreciate it if someone can explain in simple English (that is without unnecessary tech jargon)

  1. What is REST?
  2. What position it occupies in web architecture ecosystem?
  3. How tightly (or loosely) it is coupled with protocol?
  4. What are the alternatives to REST and how does REST compare with them?

I understand it may not be possible to answer this in one or two paragraphs, in that case relevant links will be highly appreciated.

lennon310
  • 3,242
Gaurav
  • 3,739

3 Answers3

43

What is REST?

REpresentational State Transfer. It describes how one system can communicate state with another. One example would be the state of a product (its name, description etc) represented as XML, JSON, or plain text. The generalised idea of state is termed a resource.

What position does it occupy in a web architecture ecosystem?

REST is commonly associated with the web services interface since HTTP is by far the most common carrier protocol. In the 7-layer model it exists at the application layer. However, see the next section.

How tightly (or loosely) it is coupled with protocol?

REST is not HTTP. It uses HTTP because in its most general form REST exists to assist a machine in mapping the concept of a verb against an arbitrary collection of nouns. HTTP contains a useful set of generic verbs (GET, PUT, PATCH etc) that can applied to arbitrary nouns expresssed as URIs using HTTP e.g. GET http://example.org/Product(54).

What are the alternatives to REST and how does REST compare with them

This is akin to asking "How RESTful is my approach?" Use the following list (summarised from the Richardson Maturity Model as described by Martin Fowler):

Level 0 - The swamp of POX

Use POST for everything (reads, writes, deletes). This is SOAP, POX, RPI etc. You're just using HTTP as a tunnel for your own protocol. You target a single endpoint that does everything based on the contents of the request body.

Level 1 - Resources

Use POST for everything. Target multiple endpoints designed to serve up information about a particular thing. You've just discovered resources.

Level 2 - HTTP verbs

Use HTTP verbs against resources. Now you're GETing it. POST is to create, PUT is to overwrite, OPTIONS for available operations, DELETE to, well, delete the resource. As a result of the use of these verbs different HTTP status codes start to become more relevant (202 ACCEPTED anyone?).

Level 3 - Hypermedia control (HATEOAS)

At this point you make the final leap and introduce hypermedia as a flow control mechanism. A REST client needs no prior knowledge about how to interact with any particular application or server beyond a generic understanding of hypermedia. This can be communicated in HTTP through the Content-Type header field. Text formats include AtomPub and (more concise) HAL, while HyperAudio works well for audio streams (see SoundCloud et al)

Gary
  • 24,440
11

While REST is an abbreviation of Representational State Transfer, it may be easier to consider the idea of performing various actions through a somewhat intuitive interface.

For example, a URL such as http://www.mysite.com/FindProduct/125/ could be interpreted as someone wanting to information on the product with an id of 125.

While REST is usually thought of in terms of HTTP, the concept could be applied to other protocols as noted in the Wikipedia reference.

Other examples of REST that may be useful:

JB King
  • 16,775
10

What is REST (in simple English)

Plain English:

REpresentational: the action of speaking or acting on behalf of someone.

State Transfer: transfer status.

Technical:

  • REST is the way HTTP should be used.
  • we do not transfer an actual object but a representation of it in a form (eg. a xml/json/text to represent a database table).
  • RESTs for exposing a public API over the internet to handle CRUD operations on data. REST is focused on accessing named resources through a single consistent interface.
  • REST is representes via some media type. Some examples of media types include XML, JSON, and RDF.
  • REST is an architectural style for resource-oriented architecture (ROA), not a spec or a standard.
  • Everything is identified by unique endpoint. i.e. There is one endpoint for each resource(data).
  • Endpoint is consist of domain name with resource address.

REST vs SOAP

Premraj
  • 916