Live data from Hacker News

RESTful APIs, the big lie

mmikowski.github.io

1–10 of 22 posts

Re: RESTful APIs, the big lie

#3
post #2

JSON-pure API? Do you mean SOAP but with JSON instead of XML?

About all I gleaned from reading it was a big list of reasons why 'RESTful' is bad, and that the main solution was to use HTTP(s) as purely a transport layer.

What, exactly the 'solution' will look like depends on future posts... however https://xkcd.com/927/ (Standards) comes to mind.

Re: RESTful APIs, the big lie

#4
post #2

JSON-pure API? Do you mean SOAP but with JSON instead of XML?

Is it so strange? XML-RPC is simpler ancestor of SOAP. JSON-RPC is a superset of XML-RPC (includes e.g. named parameters), defined over JSON instead of XML. JSON-RPC doesn't have the wide spread of XML-RPC, though.

I don't see much wrong with those, and they do much better than REST, since they already have well-defined way of signaling errors.

Re: RESTful APIs, the big lie

#5
What the author ends up proposing, as usual, is basically RPC-over-JSON. Replace JSON with XML and RPC with SOAP, and you get the sort of monster-construct the REST movement was born to fight.

This particular sentence says it all: "the message content should be independent of the transmission channel." That's the RPC dream: no matter what the pipe is, I'm sending you stuff to do. The problem, of course, is that in practice the transmission channel is never neutral: for example, HTTP and RMI are very different beasts, and in practice applications built on top of either one will end up relying on this or that assumption about the protocol, no matter how hard you try to standardize them. Same for any transmission protocol out there, really. You just have to decide when to stop trying to abstract everything away and do your work, because each additional abstraction is inevitably leaky. In this sense, REST basically tells you to stop right there and get to work. REST is not a "transmission channel", it's an application design philosophy for applications built on HTTP. End of.

Pretty much all his other objections can be fixed by using proper response codes and intelligent payloads that do not include verbs. The only verbs you need are in HTTP already - GET, POST and DELETE will cover 99% of your requirements. They make your API substantially predictable and robust. The minute you start putting verbs in payloads, you're doing RPC and you might as well use CORBA. If this is what you want, go ahead and do it, but don't say it's REST's fault if you don't understand what REST is.

Re: RESTful APIs, the big lie

#6
post #5

What the author ends up proposing, as usual, is basically RPC-over-JSON. Replace JSON with XML and RPC with SOAP, and you get the sort of monster-construct the REST movement was born to fight. This particular sentence says it all: "the message content should be independent of the transmission channel." That's the RPC dream: no matter what the pipe is, I'm sending you stuff to do. The problem, of course, is that in pr…

> [...] GET, POST and DELETE will cover 99% of your requirements.

Hardly. There's no search in these. You end up putting your query either to URL, which is hideous, or to request body, which is awful.

The only HTTP verb that can sensibly carry anything beside "create", "destroy", and "retrieve" commands is POST. This equals to operation "manipulate". And guess what? Plenty of remote interfaces use at the same time many operations that can be called "manipulate". Sticking to merely HTTP verbs is way, way too constraining.

Re: RESTful APIs, the big lie

#7
post #5

What the author ends up proposing, as usual, is basically RPC-over-JSON. Replace JSON with XML and RPC with SOAP, and you get the sort of monster-construct the REST movement was born to fight. This particular sentence says it all: "the message content should be independent of the transmission channel." That's the RPC dream: no matter what the pipe is, I'm sending you stuff to do. The problem, of course, is that in pr…

> The only verbs you need are in HTTP already - GET, POST and DELETE will cover 99% of your requirements.

To really do things for arbitrary apps without getting ugly and abusing the intended semantics, you really need at least GET, QUERY (safe, retrieves a resource specified by the combination of the URI and the request body rather than just the URI like GET), POST, PUT, PATCH, and DELETE. All but QUERY and PATCH are very widely supported now, and PATCH is fairly widely supported. QUERY isn't (there are some things like it under various names, mostly overly specific and tied to WebDAV, but nothing general purpose in an RFC or in general use.)

Re: RESTful APIs, the big lie

#8
post #6
post #5

What the author ends up proposing, as usual, is basically RPC-over-JSON. Replace JSON with XML and RPC with SOAP, and you get the sort of monster-construct the REST movement was born to fight. This particular sentence says it all: "the message content should be independent of the transmission channel." That's the RPC dream: no matter what the pipe is, I'm sending you stuff to do. The problem, of course, is that in pr…

> [...] GET, POST and DELETE will cover 99% of your requirements. Hardly. There's no search in these. You end up putting your query either to URL, which is hideous, or to request body, which is awful. The only HTTP verb that can sensibly carry anything beside "create", "destroy", and "retrieve" commands is POST. This equals to operation "manipulate". And guess what? Plenty of remote interfaces use at the same time ma…

> Hardly. There's no search in these. You end up putting your query either to URL, which is hideous, or to request body, which is awful.

We'll just have to disagree there.

In any case, if you find REST restrictive, fine, go ahead and do your RPC. Just don't try to tell me that it's anything other than RPC, with all the problems and warts we all know.

The value in REST is exactly that it forces you to simplify your interface down to basic verbs that everyone can understand and work with; if you can't do that, if additional complexity is unavoidable, then REST is not for you and you should be aware that your application is now officially complex, maybe too complex to be a public API.

From that point of view, something like SOAP is a perfectly respectable protocol and you should use that instead.

Re: RESTful APIs, the big lie

#9
post #5

What the author ends up proposing, as usual, is basically RPC-over-JSON. Replace JSON with XML and RPC with SOAP, and you get the sort of monster-construct the REST movement was born to fight. This particular sentence says it all: "the message content should be independent of the transmission channel." That's the RPC dream: no matter what the pipe is, I'm sending you stuff to do. The problem, of course, is that in pr…

> The only verbs you need are in HTTP already - GET, POST and DELETE will cover 99% of your requirements. To really do things for arbitrary apps without getting ugly and abusing the intended semantics, you really need at least GET, QUERY (safe, retrieves a resource specified by the combination of the URI and the request body rather than just the URI like GET), POST, PUT, PATCH, and DELETE. All but QUERY and PATCH are…

I agree that QUERY would be nice, to disentangle some of GET's workload. PATCH, I honestly don't care for: I'm of the opinion that one should POST (or PUT) and be damned, there are enough codes to specify what the status of the resource was before the action.

Re: RESTful APIs, the big lie

#10
post #6
post #5

What the author ends up proposing, as usual, is basically RPC-over-JSON. Replace JSON with XML and RPC with SOAP, and you get the sort of monster-construct the REST movement was born to fight. This particular sentence says it all: "the message content should be independent of the transmission channel." That's the RPC dream: no matter what the pipe is, I'm sending you stuff to do. The problem, of course, is that in pr…

> [...] GET, POST and DELETE will cover 99% of your requirements. Hardly. There's no search in these. You end up putting your query either to URL, which is hideous, or to request body, which is awful. The only HTTP verb that can sensibly carry anything beside "create", "destroy", and "retrieve" commands is POST. This equals to operation "manipulate". And guess what? Plenty of remote interfaces use at the same time ma…

>There's no search in these.

>The only HTTP verb that can sensibly carry anything beside "create", "destroy", and "retrieve" commands is POST.

So what you are saying is that a search or query is fundamentally different from the idea of "retrieve" provided by the GET verb?

Post reply on HN