What is 'Representational State Transfer'?

I have read about REST, but never really understood meaning of
‘Representational State Transfer’. I tried to read Fielding’s
dissertation, but did not understand this term and why has he used it.
What does it mean? Which state? What transfer?

Thanks,
Amita.

I for one found this post very useful.

On Mon, Apr 27, 2009 at 10:16 PM, Robert W. <

Amita B. wrote:

I have read about REST, but never really understood meaning of
‘Representational State Transfer’. I tried to read Fielding’s
dissertation, but did not understand this term and why has he used it.
What does it mean? Which state? What transfer?

I’m not sure anyone knows why Fielding used this term. I suppose he had
to call it something, so that’s what he chose.

However, I’ll try to explain it as I understand it:

Representational:
The web consists of resources in the form of web pages that are
represented using a Uniform Resource Identifier (URI). REST extends this
definition to refer to other types of resources of an application (i.e.
database tables). Which, can also be represented using a URI.
http://example.com/posts/1 represents the first Post resource in the
posts collection.

State:
This is the current state of the resources.

Transfer (or more precisely State Transfer):
The act of modifying the current state of the resources. Adding a new
one, modifying an existing one, deleting an existing one, etc.

REST defines a convention of using HTTP to both represent and change the
state of resources. That’s a close as I can come to defining
“Representational State Transfer.”

Hope that helps.

Hi –

Robert W. wrote:

Representational:
The web consists of resources in the form of web pages that are
represented using a Uniform Resource Identifier (URI). REST extends this
definition to refer to other types of resources of an application (i.e.
database tables). Which, can also be represented using a URI.
http://example.com/posts/1 represents the first Post resource in the
posts collection.

A resource in the REST sense isn’t anything as concrete as a database
table, though. It’s more conceptual. As Fielding says: “The resource is
not the storage object. The resource is not a mechanism that the server
uses to handle the storage object.”

State:
This is the current state of the resources.

Transfer (or more precisely State Transfer):
The act of modifying the current state of the resources. Adding a new
one, modifying an existing one, deleting an existing one, etc.

REST defines a convention of using HTTP to both represent and change the
state of resources. That’s a close as I can come to defining
“Representational State Transfer.”

My nutshell take on it is something like this:

A given system gives and receives representations of resources. A
resource is a very high-level construct; a representation is more
specific, and has a content-type and so forth. Resources don’t. (Even
more low-level are matters of storage, which may vary and which are not,
themselves, either resources or representations.)

A resource is always in a given state. Resource states are altered via
the exchange of representations. So if I want to correct the spelling of
my name on a site, I submit a representation of my profile with the new
spelling (probably in the form of a Web form). If I want to make sure
it’s OK, I request a representation (probably in the form of an HTML
document) to inspect.

I’ve written a bit more about this on these blog posts:

http://dablog.rubypal.com/2008/3/23/splitting-hairs-over-resource
http://dablog.rubypal.com/2008/4/24/splitting-hairs-over-resource-part-2

specifically in a Rails context. (Wow, was that more than a year ago?)

David


David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now out in PDF: The Well-Grounded Rubyist (The Well-Grounded Rubyist)
“Ruby 1.9: What You Need To Know” Envycasts with David A. Black
http://www.envycasts.com

David A. Black wrote:

Hi –

Robert W. wrote:

Representational:
The web consists of resources in the form of web pages that are
represented using a Uniform Resource Identifier (URI). REST extends this
definition to refer to other types of resources of an application (i.e.
database tables). Which, can also be represented using a URI.
http://example.com/posts/1 represents the first Post resource in the
posts collection.

A resource in the REST sense isn’t anything as concrete as a database
table, though. It’s more conceptual. As Fielding says: “The resource is
not the storage object. The resource is not a mechanism that the server
uses to handle the storage object.”

Absolutely. Thanks David for this elaboration.

A given system gives and receives representations of resources. A
resource is a very high-level construct; a representation is more
specific, and has a content-type and so forth. Resources don’t. (Even
more low-level are matters of storage, which may vary and which are not,
themselves, either resources or representations.)

A resource is always in a given state. Resource states are altered via
the exchange of representations. So if I want to correct the spelling of
my name on a site, I submit a representation of my profile with the new
spelling (probably in the form of a Web form). If I want to make sure
it’s OK, I request a representation (probably in the form of an HTML
document) to inspect.

Nice explanation. I look forward to reading your articles when I have a
few spare moments.

JDM wrote:

“Representational State Transfer defines a convention for using HTTP
to both identify and manipulate related information that is
conceptually mapped into an aggrregate construct referred to as a
Resource.”

Jim M.

Quite succinct. I like it.

David,

Your posts are certainly an interesting aside on the IMproper usage of
the term “resource”, but it doesn’t (for me) answer the original
question: “What is Representational State Transfer?”

Like Amita, I struggle with this. My hope is to someday have a
succinct way of expressing the answer, without being forced to convey
all of the detailed nuamce of Fielding’s dissertation (which I don’t
really grasp in any great detail).

I kinda like where Robet was going, but I’ll suggest a slight
rephrasing:

“Representational State Transfer defines a convention for using HTTP
to both identify and manipulate related information that is
conceptually mapped into an aggrregate construct referred to as a
Resource.”

I repeat - I don’t really understand all of the detailed nuance. I’m
struggling to create a simple articulation of the basic idea.

Is my articulation sorta, kinda, in a way, maybe correct? How can my
articulation be improved?

Jim M.

I guess I was trying to duck the issue, but I see that does nothiing
to elucidate the use of the word “Representational” in the REST name.

I’ll suggest this change (though its getting quite wordy):

“Representational State Transfer defines a convention for using HTTP
to both identify and manipulate related information that is
conceptually mapped into an aggrregate construct referred to as a
Resource, via the transfer between application components of
Representations that contain the current or intended state of that
Resource.”

Whadda ya think?

Jim M.

On Apr 28, 4:35 pm, Robert W. [email protected]

JDM wrote:

I kinda like where Robet was going, but I’ll suggest a slight
rephrasing:

“Representational State Transfer defines a convention for using HTTP
to both identify and manipulate related information that is
conceptually mapped into an aggrregate construct referred to as a
Resource.”

Thanks for the vote of confidence. I certainly don’t claim to be an
expert on the subject. There are a lot of people smarter on this stuff
than I, which is why I tried to remain somewhat abstract. I do like your
rewording of my original thought. It certainly seems like a good start.
However, as David pointed out in his excellent blog postings, this
definition may still be omitting one important aspect of REST, which is
the distinction between a “resource” and a “representation” of a
resource. I feel that I have a good mental grasp on this distinction,
even if I’m not so great at applying the concepts to the written word.