Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does using RESTful URLs buy me?

I've been reading up on REST, and I'm trying to figure out what the advantages to using it are. Specifically, what is the advantage to REST-style URLs that make them worth implementing over a more typical GET request with a query string?

Why is this URL:

    http://www.parts-depot.com/parts/getPart?id=00345

Considered inferior to this?

    http://www.parts-depot.com/parts/00345

In the above examples (taken from here) the second URL is indeed more elegant looking and concise. But it comes at a cost... the first URL is pretty easy to implement in any web language, out of the box. The second requires additional code and/or server configuration to parse out values, as well as additional documentation and time spent explaining the system to junior programmers and justifying it to peers.

So, my question is, aside from the pleasure of having URLs that look cool, what advantages do RESTful URLs gain for me that would make using them worth the cost of implementation?

like image 548
Spike Williams Avatar asked Apr 09 '10 21:04

Spike Williams


2 Answers

The hope is that if you make your URL refer to a noun then there is a better chance that you will implement the HTTP verbs correctly. Beyond that there is absolutely no advantage of one URL versus another.

The reality is that the contents of an URL are completely irrelevant to a RESTful system. It is simply an identifier.

It's not what it looks like, it is what you do with it that is important.

like image 161
Darrel Miller Avatar answered Nov 02 '22 03:11

Darrel Miller


One way of looking at REST:

http://tomayko.com/writings/rest-to-my-wife (which has now been taken down, sadly, but can still be see on web.archive.org)

So anyway, HTTP—this protocol Fielding and his friends created—is all about applying verbs to nouns. For instance, when you go to a web page, the browser does an HTTP GET on the URL you type in and back comes a web page.

...

Instead, the large majority are busy writing layers of complex specifications for doing this stuff in a different way that isn’t nearly as useful or eloquent. Nouns aren’t universal and verbs aren’t polymorphic. We’re throwing out decades of real field usage and proven technique and starting over with something that looks a lot like other systems that have failed in the past. We’re using HTTP but only because it helps us talk to our network and security people less. We’re trading simplicity for flashy tools and wizards.

like image 6
davek Avatar answered Nov 02 '22 03:11

davek