3 ms·
This is an ad for intercooler.js. If I make an API request to a remote server, I want data back, which I will then process in some way. It might not be display
by Animats 11y ago
This is an ad for intercooler.js.
If I make an API request to a remote server, I want data back, which I will then process in some way. It might not be displayed to a user at all. I don't want HTML to display to the user. That's too hard to process in a program. Also, if it returns HTML, it will probably have an ad in it, or Javascript, or a tracker, or something else obnoxious.
If you're accessing an API which deals with financial data, you usually plan to graph it or compare it or issue a trade order. The server has no idea what you want the data for, and doesn't have a need to know. You don't want HTML back; then you'd have to scrape the numbers out of that.
JSON in, JSON out as an RPC mechanism is useful. It's easier to use than SOAP, and few SOAP servers seem to actually obey their published schema anyway. (Run a checking SOAP client and call something complicated to see this.)
- carsongross 11y agoWell, it's kind of an ad of course (although intercooler is free and open source, with no company offering any services around it) but there is a deeper point here. I see a lot of confusion in these comments: I'm not advocating HTML as a general API for use with native mobile clients, SPAs, etc. And I'm saying, explicitly, that REST-ful JSON, as implemented by most developers, has proven a bad choice for that need. And I think that is because HATEOAS has never found a natural expression in JSON. So I'm saying: if you want to follow REST-ful principles for your web application, you should abandon a data-level API entirely, and move to a partial HTML model instead, where HTML allows you to naturally leverage HATEOAS without even really thinking about it. Ad, deep insight, whatever. It's a thing.
- icebraining 11y agoThe thing is, if one wants to follow REST-ful principles in web applications, one can just write JSON documents with links. The fix is not hard nor complicated - which, to me, shows that the problem is not that people really want to use REST but can't due to JSON, and must be something else. In my opinion, people don't really want to use REST, either because they don't really understand it (as seen by the number of RPC APIs being described as "RESTful") or they just don't think it's the best solution for their problem. That said, Intercooler.js can still be a very useful library, but I think it might be successful despite REST, not because of it.
- carsongross 11y agoI don't agree: the fix is hard, because not only do you have to pick one of the many at-war non-standard standards for your links in JSON, but then clients must figure out how to interpret the links. I think the empirical evidence of the last two decades overwhelmingly supports this conclusion. This is what HTML gives developers: they don't even realize they are satisfying the HATEOAS constraint because it is simply so natural.