News for hackers. Stuff that matters.
Re:The Future is Hypermedia APIs by paul_odin on Thursday December 20, 2012 @07:34PM (#4950863)
Is there a list of Hypermedia-esque APIs in use today (apart from sitemap)? I can find lots of explanations of the concept but it's hard to find examples.

The closest I can think of is the way some APIs handle pagination (GitHub and Recurly for example) by using Link: rel=next/prev/start headers rather than through GET parameters, which in principle would allow a generic REST client to iterate through results on its own.

Re:The Future is Hypermedia APIs by mjallday on Thursday December 20, 2012 @09:33PM (#4951211)
Like steveklabnik mentioned, take a look at the Balanced API, here's an example you can run yourself using a test marketplace:

    curl https://api.balancedpayments.com/v1/marketplaces/TEST-MP6IEymJ6ynwnSoqJQnUTacN -u 7b7a51ccb10c11e19c0a026ba7e239a9:
To keep this thread free of tons of code samples I've included the result @ https://gist.github.com/4350290

You can see in our python client how we then parse - https://github.com/balanced/balanced-python/blob/master/bala... - the result of this which then consumes these URIs and turns them into dynamic resources attached to whatever object you're looking at.

This means you can do this:

    debit = balanced.Debit.find(uri)
    debit.account.cards.all()  # get a list of all cards associated with the account that created this debit
And the client does not have to know anything about the fact that debits have an account property, or that accounts have a cards resource underneath them.
Re:The Future is Hypermedia APIs by mahmoudimus on Thursday December 20, 2012 @10:02PM (#4951297)
I think we should probably write about https://github.com/bninja/wac and how our Balanced Python client influences it. Gone are the days when your internal services need to sync on some kind of schema.

We make changes to our internal services all the time and HATEOAS allows us to ensure our services are properly functioning without breaking contractual API obligations.

I can see why most developers resist the urge to try hypermedia APIs and it's honestly because the tooling to build services and clients just aren't there.

This is why I'm a big fan of the https://github.com/rails-api/rails-api project. It's essentially accepting this deficiency, has some brilliant minds behind it and as a consequence, I'm sure the tooling to be built around it will be amazing; it's definitely one to follow.

Some more resources:

* https://github.com/rails-api/rails-api

* http://django-rest-framework.org/

Re:The Future is Hypermedia APIs by steveklabnik on Thursday December 20, 2012 @07:39PM (#4950877)
Re:The Future is Hypermedia APIs by technoweenie on Thursday December 20, 2012 @08:37PM (#4951066)
$ curl https://api.github.com

We're experimenting with more :)

Re:The Future is Hypermedia APIs by steveklabnik on Thursday December 20, 2012 @09:24PM (#4951180)
<3 <3 <3.

I really need to buy you a beer sometime.

Re:The Future is Hypermedia APIs by mahmoudimus on Thursday December 20, 2012 @09:53PM (#4951269)
That's cool :) I agree with steveklabnik, I want to see what Balanced can do to learn from Github's experiments in hypermedia APIs
Re:The Future is Hypermedia APIs by dreamdu5t on Thursday December 20, 2012 @10:09PM (#4951313)
So sexy.
Re:The Future is Hypermedia APIs by gcampbell on Thursday December 20, 2012 @09:24PM (#4951183)
What are the advantages/disadvantages of serializing links in the body JSON (i.e. HAL) vs. using the Link header?
Re:The Future is Hypermedia APIs by politician on Thursday December 20, 2012 @09:41PM (#4951237)
This is a good question, and the answer is philosophical purity and pragmatism. Philosophically, some people believe that this information should be encapsulated in the HTTP response body, while others believe that they should be able to leverage all of the parts of the HTTP spec including the response headers. Pragmatically, certain environments make it harder or easier to access certain parts of request and response objects, but the lowest common denominator is the body content.