Live data from Hacker News

Getting hyper about hypermedia APIs

37signals.com

41–50 of 73 posts

Re: Getting hyper about hypermedia APIs

#41
post #35
post #9

Earlier quoted context omitted.

What concerns me about Hypermedia APIs is that folks are using the same sorts of grandiose, architecture astronaut-y stuff that we got out of the last two failed revolutions. You owe it to yourself to read the HAL+JSON specification: http://stateless.co/hal_specification.html Anyone who considers a three-page spec like that astronautics probably has a low capacity for complex thought.

A hint: when trying to convince, it's not a great idea to passive-aggressively insult the other party. Since they're human too, they will probably just get pissed off and write you off as an asshole. Like what I'm doing right now.

Given the level of respect I have for the OP's exhaustively researched points, I should not have said a thing. Someone on the Internet is wrong. My mistake.

Re: Getting hyper about hypermedia APIs

#42
post #9

Hypermedia hype has always struck me as parallel to the "semantic web" nonsense from the late 90s. "If we just use RDF triples to encode everything then machines can learn that apples are fruits and fruits are good for you, thus apples are good for you! Huzzah!" Then, Microsoft invented SOAP. "If we just have a WSDL that explains all of our API, then we can have automated methods to communicate between services! Prog…

What concerns me about Hypermedia APIs is that folks are using the same sorts of grandiose, architecture astronaut-y stuff that we got out of the last two failed revolutions. You owe it to yourself to read the HAL+JSON specification: http://stateless.co/hal_specification.html Anyone who considers a three-page spec like that astronautics probably has a low capacity for complex thought.

Requiring a low capacity for complex thought sounds like a good API...

Re: Getting hyper about hypermedia APIs

#43
post #18

Earlier quoted context omitted.

Do you mean like http://haltalk.herokuapp.com/rels/signup ? But every site will have different requirements or mandatory fields on signup, so there's still no "discoverable" way to sign up to Amazon and eBay and Google without a human looking at http://amazon.com/rels/signup and http://ebay.com/rels/signup , etc., in which case you're back to still needing to read the documentation. I guess it's a slight improvement…

it is an example of a discoverable API with discoverable documentation though, which is what you were asking for I think.. maybe not?

Ah, maybe I misunderstand what you're trying to do. I thought Hal was trying to make it possible to write clients that can buy from Amazon or eBay without knowing anything about the specifics of either. But actually what it's attempting is a sort of machine-assisted documentation system? (Since you still need a human to read the docs to find out how to signup, place orders, and so on.) I can see how that might work, but it doesn't seem like an important problem to solve.

Re: Getting hyper about hypermedia APIs

#44

Earlier quoted context omitted.

I'm one of the biggest proponents of hypermedia (been speaking about it for the last 18~ months at conferences) and I think the semantic web is bullshit.

Hi Steve, Thanks for the reply. I'm basing my interpretation off of your http://designinghypermediaapis.com site and the associated listserv, so either I'm misinterpreting it, or we have a difference of opinion as to the complexity and utility of the proposed solution(s). My fear is we're redefining WSDL in JSON's clothing. Yes, adding hrefs to the API isn't complex -- but the code to actually do something with it is…

> My fear is we're redefining WSDL in JSON's clothing.

Absolutely not. There is a 'WSDL in REST' called WADL, and it's _terrible_. WSDL/WADL is like static typing: you have to declare everything up front, it's super rigid, and prone to breaking. Hypermedia is like dynamic typing: it all happens late bound, it's flexible, and open to change.

> the code to actually do something with it is, and that's where my spidey sense starts tingling

Here's one of the simplest examples I can show you: the 'hypermedia proxy pattern':

https://gist.github.com/3172911

Here's the core of the code: https://gist.github.com/3172911#file-client-rb-L27-L37

This says "parse the links out and save them. When I try to load a name, if it doesn't exist, go fetch it from the link pointed to by 'self.'

This allows you to change the client behavior by modifying the server: by compressing or expanding responses, the client makes more or less requests without changing its code. Jon Moore demonstrates this with Java, Python, and XHTML here: https://vimeo.com/20781278 I demo'd this exact example at the end of my talk here: http://oredev.org/2012/sessions/designing-hypermedia-apis

Did you see my Shoes Microblogging example for ALPS? https://gist.github.com/2187514

The meat of it is here: https://gist.github.com/2187514#file-microblog_client-rb-L33... This isn't the best factored example, but I wanted to show a tiny client: this is a GUI program that can read from any ALPS compliant server (like http://rstat.us/) and read/post new status updates.

------------------------------------------------------------

What I will say is this: I don't feel it's _harder_, but I do feel it's _different_. Just like if you try to write Java in Ruby, if you try to write hypermedia APIs like another style, it will feel hard and foreign. I think it's easier to implement a number of clients over time for a hypermedia service, than it is to write a bunch of clients over time for a "Rails REST" one.

Re: Getting hyper about hypermedia APIs

#45
post #43

Earlier quoted context omitted.

it is an example of a discoverable API with discoverable documentation though, which is what you were asking for I think.. maybe not?

Ah, maybe I misunderstand what you're trying to do. I thought Hal was trying to make it possible to write clients that can buy from Amazon or eBay without knowing anything about the specifics of either. But actually what it's attempting is a sort of machine-assisted documentation system? (Since you still need a human to read the docs to find out how to signup, place orders, and so on.) I can see how that might work,…

That is one of the benefits that relates to documentation, which is the part of your comment I was responding too.

The larger goal of hal+json is to establish some conventions for linking that allow the development of generic tools for doing hypermedia. Not to create magical machine clients that can interact with any random API you point them at. Nobody made that argument so I don't know why DHH addressed it in his post. I'm guessing he ran out of things to be an angry-pragmatist about.

Re: Getting hyper about hypermedia APIs

#46

Earlier quoted context omitted.

Hi Steve, Thanks for the reply. I'm basing my interpretation off of your http://designinghypermediaapis.com site and the associated listserv, so either I'm misinterpreting it, or we have a difference of opinion as to the complexity and utility of the proposed solution(s). My fear is we're redefining WSDL in JSON's clothing. Yes, adding hrefs to the API isn't complex -- but the code to actually do something with it is…

> My fear is we're redefining WSDL in JSON's clothing. Absolutely not. There is a 'WSDL in REST' called WADL, and it's _terrible_. WSDL/WADL is like static typing: you have to declare everything up front, it's super rigid, and prone to breaking. Hypermedia is like dynamic typing: it all happens late bound, it's flexible, and open to change. > the code to actually do something with it is, and that's where my spidey se…

Thanks, I will dig into those examples!

Re: Getting hyper about hypermedia APIs

#47

Earlier quoted context omitted.

What are the best options to implement that for an API backend with Rails a javascript library/framework for the interface?

The current Rails Party Line is "Jbuilder + you don't need integration" https://twitter.com/dhh/status/281802247480958976 https://twitter.com/dhh/status/281802391316201472 Some members of the core team and I have started a "Rails API" project specifically to explore these possibilities, and to extract common patterns from the apps we build: http://github.com/rails-api This will encompass hypermedia and non-hypermedia…

We also have developed custom Python tools and frameworks that help us with our API at https://balancedpayments.com/

If there's enough interest, I'd love to share some of our ideas with the Rails community and discuss some potential downfalls and successes we've had and why we needed to build these tools internally.

I'm sure Rails would benefit a lot from these.

Love love love the hypermedia work -- keep it up!

Re: Getting hyper about hypermedia APIs

#48

I wrote the spec for application/hal+json that got compared to WS-star , here's where I'm coming from: JSON doesn’t have links. Establishing some basic conventions for that makes complete sense. Defining those conventions is called a spec. Giving a payload that follows conventions a name also makes sense. Establishing that is called registering a media type identifier. It makes no sense to keep reinventing the linkin…

JSON and other non-natively-hyperlinked-media (e.g PNG, MP3, etc) can use the Link header to add hyperlinks. It's HTTP that is hypermedia aware, not the content-type, so you dont have to go out and invent image/png+hal.

TL;DR You dont need to create a new media-type to make JSON hypermedia. All requests are hypermedia by virtue of the fact that it uses HTTP as the transport protocol.

Re: Getting hyper about hypermedia APIs

#49

According to hypermedia lore, you will be able to willy nilly change your URLs without needing to update any clients. But that’s based on the huge assumption that every API call is going to go through the front door every time and navigate to the page they need. That’s just not how things work. This is missing forest for the trees. The point is not that you, the API implementor, will be able to change URLs willy nill…

> and tomorrow someone creates Blinkr, which implements the same API, So the benefit of hypermedia apis is predicated on something happens that almost never ever happens?

RSS is one prominent example of an API that many different sites implement.

And it's a media type! With Links!

Re: Getting hyper about hypermedia APIs

#50

Earlier quoted context omitted.

> My fear is we're redefining WSDL in JSON's clothing. Absolutely not. There is a 'WSDL in REST' called WADL, and it's _terrible_. WSDL/WADL is like static typing: you have to declare everything up front, it's super rigid, and prone to breaking. Hypermedia is like dynamic typing: it all happens late bound, it's flexible, and open to change. > the code to actually do something with it is, and that's where my spidey se…

Thanks, I will dig into those examples!

Awesome. Please let me know, and post to the list if you have questions.

By the way, my student loan creditors thank you. :)

(I'm planning on a major new iteration of the book project in the new year that's much more linear, clear, and practice driven rather than theory.)

Post reply on HN