Live data from Hacker News

Most RESTful APIs aren't really RESTful

florian-kraemer.net

261–270 of 580 posts

Re: Most RESTful APIs aren't really RESTful

#261
post #246

Earlier quoted context omitted.

How does the UI check if certain operations are available?

OPTIONS https://datatracker.ietf.org/doc/html/rfc2616 More links here: https://news.ycombinator.com/item?id=44510745

Or probably just an Allow header on a response to another query (e.g. when fetching an object, server could respond with an Allow: GET, PUT, DELETE if the user has read-write access and Allow: GET if it’s read-only).

Re: Most RESTful APIs aren't really RESTful

#262

I sympathize with the pedantry here and found Fielding's paper to be interesting, but this is a lost battle. When I see "REST API" I can safely assume the following: - The API returns JSON - CRUD actions are mapped to POST/GET/PUT/DELETE - The team constantly bikesheds over correct status codes and at least a few are used contrary to the HTTP spec - There's a decent chance listing endpoints were changed to POST to su…

[deleted]

Re: Most RESTful APIs aren't really RESTful

#263
post #249

Earlier quoted context omitted.

> HTTP/JSON API works too, but you can assume it's what they mean by REST. This is the kind of slippery slope where pedantic nitpickers thrive. The start to complain that if you accept any media type other than JSON then it's not "REST-adjacent" anymore because JSON is in the name and some bloke wrote down somewhere that JSON was a trait of this architectural style. In this sense, the term "RESTful" is useful to shut…

> The start to complain that if you accept any media type other than JSON then it's not "REST-adjacent" anymore because JSON is in the name and some bloke wrote down somewhere that JSON was a trait of this architectural style. wat? Nowhere is JSON in the name of REpresentational State Transfer. Moreover, sending other representations than JSON (and/or different presentations in JSON) is not only acceptable, but is re…

> Nowhere is JSON in the name of REpresentational State Transfer.

If you read the message you're replying to, you'll notice you are commenting on the idea of coining the concept of HTTP/JSON API as a better fitting name.

Re: Most RESTful APIs aren't really RESTful

#264

Earlier quoted context omitted.

REST means, generally, HTTP requests with json as a result.

It also means they made some effort to use appropriate http verbs instead of GET/POST for everything, and they made an effort to organize their urls into patterns like `/things/:id/child/:child_id`. It was probably an organic response to the complexity of SOAP/WSDL at the time, so people harping on how it's not HATEOAS kinda miss the historical context; people didn't want another WSDL.

>> /things/:id/child/:child_id

It seems that nesting isn't super common in my experience. Maybe two levels if completely composite but they tend to be fairly flat.

Re: Most RESTful APIs aren't really RESTful

#265

Earlier quoted context omitted.

This is true, but isn’t this quite far away from the normal understanding of API, which is an interface consumed by a program? Isn’t this the P in Application Programming Interface? If it’s a human at the helm, it’s called a User Interface.

I agree that's a common understanding of things, but I don't think that it's 100% accurate. I think that a web browser is a client program, consuming a RESTful application programming interface in the manner that RESTful APIs are designed to be consumed, and presenting the result to a human to choose actions. I think if you restrict the notion of client to "automated programs that do not have a human driving them" th…

If you allow the notion of client to include "web browser driven by humans", then what is it about Fielding's dissertation that is considered so important and original in the first place? Sure it's formal and creates some new and precise terminology, but the concept of browsing was already well established when he wrote it.

Re: Most RESTful APIs aren't really RESTful

#266
post #249

Earlier quoted context omitted.

> The start to complain that if you accept any media type other than JSON then it's not "REST-adjacent" anymore because JSON is in the name and some bloke wrote down somewhere that JSON was a trait of this architectural style. wat? Nowhere is JSON in the name of REpresentational State Transfer. Moreover, sending other representations than JSON (and/or different presentations in JSON) is not only acceptable, but is re…

> Nowhere is JSON in the name of REpresentational State Transfer. If you read the message you're replying to, you'll notice you are commenting on the idea of coining the concept of HTTP/JSON API as a better fitting name.

Read messages before replying? It's the internet! Ain't no one got time for that

:)

Re: Most RESTful APIs aren't really RESTful

#267

Earlier quoted context omitted.

Isn't that fairly straightforward? PUT for full updates and PATCH for partial ones. Does anybody do anything different?

Lots of people make PUTs that work like PATCHes and it drives me crazy. Same with people who use POST to retrieve information.

Well you can't reliably use GET with bodies. There is the proposed SEARCH but using custom methods also might not work everywhere.

Re: Most RESTful APIs aren't really RESTful

#268

Earlier quoted context omitted.

HATEOAS adds lots of practical value if you care about discoverability and longevity.

Discoverability by whom, exactly? Like if it's for developer humans, then good docs are better. If it's for robots, then _maybe_ there's some value... But in reality, it's not for robots. HATEOAS solves a problem that doesn't exist in practice. Can you imagine an API provider being like, "hey, we can go ahead and change our interface...should be fine as long as our users are using proper clients that automatically di…

> If it's for robots, then _maybe_ there's some value...

Nah, machine readable docs beat HATEOAS in basically any application.

The person that created HATEOAS was really not designing an API protocol. It's a general use content delivery platform and not very useful for software development.

Re: Most RESTful APIs aren't really RESTful

#270
I see a lot of people who read Fielding's thesis and found it interesting.

I did not find it interesting. I found it excessively theoretical and proscriptive. It led to a lot of people arguing pedantically over things that just weren't important.

I just want to exchange JSON-structured messages over HTTP, using the least amount of HTTP required to implement request and response. I'm also OK with protocol buffers over grpc, or really any decent serialization technology over any well-implemented transport. Sometimes it's CRUD, sometimes it's inference, sometimes it's direct actions on a server.

Hmm. I shoudl write a thesis. JSMOHTTP (pronounced "jizmo-huttup")

Post reply on HN