52

I understand (I think) the basic idea behind RESTful-ness. Use HTTP methods semantically - GET gets, PUT puts, DELETE deletes, etc... Right? thought I understood the idea behind REST, but I think I'm confusing that with the details of an HTTP implementation. What is the driving idea behind rest, why is this becoming an important thing? Have people actually been using it for a long time, in a corner of the internets that my flashlight never shined upon?


The Google talk mentions Atom Publishing Protocols having a lot of synergy with RESTful implementations. Any thoughts on that?
Chris Marasti-Georg
  • 34,091
  • 15
  • 92
  • 137
  • @Graeme REST isn't limited to HTTP, is it? – Chris Marasti-Georg Oct 28 '08 at 13:55
  • It pretty much is limited to HTTP http://en.wikipedia.org/wiki/Representational_State_Transfer – kenny Oct 28 '08 at 13:57
  • 1
    I think it's more accurate to say that HTTP is a REST implementation. – bryanbcook Oct 28 '08 at 14:15
  • 11
    No. REST is not limited to HTTP. Nor is HTTP a REST implementation. Using HTTP as it is intended is not in itself RESTful. REST is independent of any single communication protocol. Please reference authoritative sources like the actual dissertation by Fielding and don't spread misinformation, or choose a different buzzword (@bryanbcook, Kenny) – aehlke Jul 20 '09 at 17:18
  • 2
    To expand on @aehlke comment, HTTP is only an example of a tunnel for connecting components of a system. REST architectural style is broken into data elements (resources and representations), components (servers and clients that manage & prepare data to be communicated), and connectors (actual communicators of data, HTTP is an option). – Sam Berry Sep 18 '14 at 04:48

5 Answers5

55

This is what REST might look like:

POST /user
fname=John&lname=Doe&age=25

The server responds:

201 Created
Location: /user/123

In the future, you can then retrieve the user information:

GET /user/123

The server responds (assuming an XML response):

200 OK
<user><fname>John</fname><lname>Doe</lname><age>25</age></user>

To update:

PUT /user/123
fname=Johnny
Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
pbreitenbach
  • 11,261
  • 3
  • 33
  • 24
19

Here's my view...

The attraction to making RESTful services is that rather than creating web-services with dozens of functional methods, we standardize on four methods (Create,Retrieve, Update, Destroy):

  • POST
  • GET
  • PUT
  • DELETE

REST is becoming popular because it also represents a standardization of messaging formats at the application layer. While HTTP uses the four basic verbs of REST, the common HTTP message format of HTML isn't a contract for building applications.

The best explanation I've heard is a comparison of TCP/IP to RSS.

Ethernet represents a standardization on the physical network. The Internet Protocol (IP) represents a standardization higher up the stack, and has several different flavors (TCP, UDP, etc). The introduction of the "Transmission Control Protocol" (guaranteed packet delivery) defined communication contracts that opened us up to a whole new set of services (FTP, Gopher, Telnet, HTTP) for the application layer.

In the analogy, we've adopted XML as the "Protocol", we are now beginning to standardize message formats. RSS is quickly becoming the basis for many RESTful services. Google's GData API is a RSS/ATOM variant.

The "desktop gadget" is a great realization of this hype: a simple client can consume basic web-content or complex-mashups using a common API and messaging standard.

Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
bryanbcook
  • 16,210
  • 2
  • 40
  • 69
12

HTTP currently is under-used and mis-used.

We usually use only two methods of HTTP: GET and POST, but there are some more: DELETE, PUT, etc (http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html)

So if we have resources, defined by RESTful URLs (each domain object in your application has unique URL in form of http://yoursite.com/path/to/the/resource) and decent HTTP implementation, we can manipulate objects in your domain by writing sentences:

GET http://yoursite.com/path/to/the/resource

DELETE http://yoursite.com/path/to/the/resource

POST http://yoursite.com/path/to/the/resource

etc

the architecture is nice and everything.

but this is just theoretical view, real world scenarios are described in all the links posted in answers before mine.

miceuz
  • 3,327
  • 5
  • 29
  • 33
  • 2
    URI naming conventions is not part of REST. That is an out-of-band convention. Resource navigation must be hypertext-driven. GET/DELETE/POST/PUT is 'using HTTP correctly' but not necessarily REST. – aehlke Jul 20 '09 at 17:24
10

Lets go to history, Talk about the Roy Fielding Research – “Architectural Styles and the Design of Network-based Software Architectures“. Its a big paper and talks a lot of various stuff. But as a standard engineer How you would like to explain the clear meaning of REST (Representational State Transfer), and what is its Architectural Style.

Here is my way to explain – “What is REST”.

See this www(world wide web) running on top of various hardwares e.g. routers,servers,firewalls, cloud infrastructures,switches,LAN,WAN. The overall objective of this www(world wide web) to distribute hypermedia. This world wide web equipped with various services e.g. informational based services, websites, youtube channels, dynamic websites, static websites. This world wide web uses HTTP protocol to distribute hypermedia across the world with a client/server mechanism. This HTTP Protocol works on top of TCP/IP or other appropriate network stack.

This HTTP protocol is using eight methods to manage the ‘protocol of distribution’ or ‘Architectural Style of Distribution’. Those eight methods are namely : OPTIONS,GET,HEAD,POST,PUT,DELETE,TRACE,CONNECT.

But on Top of this HTTP, web applications are using its own way of distributing hypermedia e.g web applications are using web services which are highly tied with clients and servers ‘or’ web applications are using its own way of designed client/server mechanism to make such distribution channel on top of HTTP.

What Roy Fielding Research says , that these eight methods OPTIONS,GET,HEAD,POST,PUT,DELETE,TRACE,CONNECT of HTTP are so successful to deliver HyperMedia to all across the world on top of variety of hardware resources and network stacks with client/server mechanism, Why don’t we use the similar strategy with our web based application as well. On this GET,POST,DELETE and PUT are used the most. so four methods deliver HyperMedia to all across the world.

In REST API Architecture Style application, a web application need to design the business logic(resides in a server e.g. Tomcat,Apache HTTP) with all set of object entities(e.g. Customer is an entity) and possible operations(e.g.‘Retrieve Customer Information based on a customer id’) on them. Those possible operations with these entities should be designed with four main operations or methods namely- Create,Retrieve,Update,Delete. These entities called as resources and these are presented or represented in a form e.g. JSON or XML or something else. We have Client(Browsers) who calls Create,Retrieve,Update,Delete (CRUD) methods to perform the appropriate function on such resource resides in the Server.

But as explained the concept of Representation, means the way entities of business logic or objects are represented. but what about with ‘State Transfer’ ?.

The State Transfer, its talks about the “state of communication” from Client to Server. It talks about the design of ‘state transfers’ from Client to Server e.g. Client first called the operation ‘Create Customer’, after calling this what would be next state of customer or states of customer which ‘client’ can call. Its state may be to ‘retrieve the created client data’, ‘update the client data’ or what

Sumit Arora
  • 5,051
  • 7
  • 37
  • 57
5

REST is an architecture where resources are defined and addressed.

To understand REST best, you should look at the Resource Oriented Architecture (ROA) which gives a set of guidelines for when actually implementing the REST architecture.

REST does not need to be over HTTP, but it is the most common. REST was first created by one of the creators of HTTP though.

Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
  • 2
    The Wikipedia article is not based on authoritative sources and is rather confused and misinformed. – aehlke Jul 20 '09 at 17:21
  • @Wahnfrieden: Mainly the link is to show reference to ROA being something that exists and not something I made up. The content of my answer was based on ROA not the content of the wikipedia article. – Brian R. Bondy Aug 05 '10 at 16:32
  • 1
    Yet you still phrased it as "To understand REST best, you should look at the " which is maybe misleading. Thanks for clearing it up though. I have a huge problem with REST on Wikipedia. – aehlke Aug 08 '10 at 22:59