85

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,132
  • 6
  • 16
  • 33
Gaurav
  • 3,729
  • 2
  • 25
  • 43
  • I find this to be informative, yet not too detailed: http://www.ibm.com/developerworks/webservices/library/ws-restful/ – NoChance Apr 18 '12 at 01:07
  • 6
    Try this - http://tomayko.com/writings/rest-to-my-wife – talonx Dec 05 '10 at 11:14
  • I wonder if this questions can be considered answered? – Gary Jul 29 '13 at 15:34
  • @GaryRowe I had marked one answer, guess it was removed for some reason. I don't understand this site. – Gaurav Aug 01 '13 at 09:57
  • @Gaurav Yeah, answers seem to come and go. It's all a bit odd really. – Gary Aug 01 '13 at 19:09
  • https://youtu.be/xkKcdK1u95s?list=PLqq-6Pq4lTTZh5U8RbdXq0WaYvZBz2rbn – Mangesh Ghotage Jan 07 '16 at 05:08
  • 1
    None of the answers below use the word "idempotent." You should look it up: idempotency is an important aspect of any RESTful architecture. – Solomon Slow Jan 12 '16 at 17:24
  • In simplest words, in the REST architectural style, data and functionality are considered resources and are accessed using Uniform Resource Identifiers (URIs). The resources are acted upon by using a set of simple, well-defined operations. The clients and servers exchange representations of resources by using a standardized interface and protocol – typically HTTP. - Source - http://restfulapi.net/ – Lokesh Gupta Mar 25 '17 at 19:02
  • [How I explained REST to my rubber duck](https://penteract.net/Blogs/PenteractBlog/Blog02/Developing/Web/General/What-is-REST_0.aspx) is pretty simple. – User42 Jul 28 '17 at 10:05

3 Answers3

44

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,420
  • 9
  • 63
  • 108
  • you say "REST is not HTTP", but Roy Fielding seems pretty fixated on the idea that _hypertext_ is a requirement, what with the whole HATEOAS deal without which -- according to him -- you aren't doing "proper" REST. While hypertext != HTTP, I wonder how much you can actually do outside HTTP... – Andres F. Apr 23 '12 at 17:28
  • According to this (http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven#comment-718) Roy Fielding makes the point that hypertext, or its subset, hypermedia, can be expressed outside of HTML just so long as it supports linking of some kind. – Gary Apr 23 '12 at 19:47
  • 3
    HTTP works well with REST because it offers standardised verbs for working with URIs that represent nouns in REST in a stateless protocol. Ideal. However in his dissertation (http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm) he notes that "REST does not restrict communication to a particular protocol, but it does constrain the interface between components, and hence the scope of interaction and implementation assumptions that might otherwise be made between components." Thus a full FTP implementation is unlikely to be RESTful without client-side state management. – Gary Apr 23 '12 at 19:54
  • 2
    +1 for the Martin Fowler link. As usual Martin Fowler has written an article that describes a concept in the most clear and concise possible way – Tom Carter Apr 24 '12 at 09:33
  • you covered `state transfer` not representation. the action of speaking or acting on behalf of someone is representation how it works in this context? – Premraj Jul 02 '15 at 02:01
  • @premraj You may be confusing "representation" with "delegation" or perhaps "acting as a proxy for an individual". In REST "representation" is the manifestation of data in terms the client can work with. – Gary Jul 02 '15 at 20:36
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,795
  • 1
  • 40
  • 76
  • 2
    Thanks for the link to "Learn REST: A Tutorial"! That's the first tutorial I've read that leaves me with the feeling I've learned something concrete. Everything else I've read (including the Wikipedia article) describe REST in only the most abstract ways, surrounded by technical jargon. – Avian00 Jul 09 '13 at 09:08
  • first link is not working. Your answer is helpful nevertheless!! – StatguyUser Apr 11 '17 at 08:35
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
  • 836
  • 10
  • 17