doubledee — 2012-02-10T12:01:04-05:00 — #1
Can someone explain to me - in plain terms - what "RESTful" is??
(I looked online and my eyes glazed over after the first paragraph...)
wwb_99 — 2012-02-10T13:26:39-05:00 — #2
The short, short, short version would be "embracing HTTP as a messaging layer." Beyond that it means lots of different things to different people. Perhaps you've got a more pointed question here . . .
doubledee — 2012-02-10T13:31:55-05:00 — #3
I was looking for Streaming Video Web Hosts and I saw that term a couple of times...
I've heard developers at work use it too.
Never really knew what it meant, and was hoping to get a better understanding so when it comes up again I'll know what it is.
samanime — 2012-02-10T16:31:09-05:00 — #4
Usually it's a type of web service or API, which you can interface with to get data from external systems into your system.
RESTful is opposed to something like SOAP. They're both usually web services, but they work differently. The big key with RESTful web services is they are "stateless", which means each transaction between it is a complete entity all on it's own. (As opposed to SOAP where you may do something like login, then have a persisting connection).
The other big thing is it usually uses the HTTP layer as it's meant to be used. A lot of APIs have you do something like get your info from a URL:
A RESTful API would have you put this as a URL usually
Which translates into a HTTP GET request:
HTTP 1.1 GET /api/books/fun/10
That's not much different. But say you want to create a new user. A non-RESTful API may have you do something like:
which translates to:
HTTP 1.1 GET /makeuser.php?name=bob&password=tooth
However, that's not using HTTP GET properly, since GET should only get info and never change it.
A proper RESTful API would likely have you use PUT instead. Something like:
HTTP 1.1 PUT /makeuser/bob/tooth
Making proper use of the HTTP protocol.
doubledee — 2012-02-10T16:37:45-05:00 — #5
scallioxtx — 2012-02-10T23:53:14-05:00 — #6
@samanime; minor point, but IIRC POST is used to create entities whereas PUT is used for updating existing ones.
Other than that I completely agree with what you said
samanime — 2012-02-13T11:07:09-05:00 — #7
Completely correct, thanks for the correction. =p
sg707 — 2012-02-21T17:26:54-05:00 — #8
I've heard of many variations. Some developers suggest that if you're querying or doing any kind of CRUD database operations that RESTful service is the way to go. If you're doing any actions through HTTP, like login/logout/search/verbs than you should use Web Service. Then to make things more confusing, they throw the term RESTful Web Service. Anyways, I look at RESTful service as a nice URL pattern service and nothing more.
samanime — 2012-02-21T19:59:42-05:00 — #9
Here is a great write-up of the various types of web service APIs: http://blog.steveklabnik.com/posts/2012-02-13-an-api-ontology
thereddevil — 2012-02-22T16:20:16-05:00 — #10
That is wrong when considering a true REST approach.
PUT is used both to create and replace entities.
POST is used to create records under another entity.
-To create/update a user account we would use PUT.
-To add another chapter to a book we would use POST (in this case book would be an entity already created by PUT).
That is a very simple example, but I hope it is sufficient to describe the difference.
Personally I don't like a pure/true REST approach to an API, as it does limit you somewhat in what the API can and cannot do.
The benefit of a pure REST approach is speed, if you can use this you will see that it is a lot faster than other options if the web server that host the API is configured properly.
With other words, don't be afraid to go for a "*******" (hybrid) API, taking the best part from the different architecture that is out there.
EDIT: Well, I guess the "bad word" system is tuned a little too high when it remove valid words like b a s t a r d...