HAL: client-defined, server-side executed '_embedded' resolution

47 views
Skip to first unread message

Matthew Bishop

unread,
Sep 6, 2016, 8:02:08 PM9/6/16
to API Craft
I'm looking at supporting the HAL format for an existing hypermedia API that uses a 'zoom' or 'expand' query parameter to embed related links in a single request. This means the client decides what to embed, and the server does the actual embedding. It all happens in a single request, not with multiple requests like Traverson does.

Has anyone seen / implemented this kind of functionality with a HAL API? I am seeing if the query parameter has been figured out already, and if anyone has written a server-side embedding engine to perform the actual work on the server.

Michael Tiller

unread,
Sep 6, 2016, 9:03:21 PM9/6/16
to api-...@googlegroups.com
Matt,

  I have done something like this.  The framework I've created uses a query language that allows the client to describe what it is interested in and then the server, as you say, essentially traverses the graph of resources on the server side.

  I'm not using HAL, but the principle really doesn't change.  I'm using Siren and much of the code is related to traversing the relations, so I would imagine the same concepts would apply in both cases.

  To be honest, I was trying to figure out exactly what should be in the query language.  I looked at various examples and tried to come up with something minimalistic yet sufficient.  It is entirely possible that the query language could have been better, but it seems quite reasonable to me.  It allows for not only selecting what relations it is interested in following, but it includes "skip/limit" functionality, sorting, filtering by resource properties and metadata.

--
Mike


On Tue, Sep 6, 2016 at 8:02 PM, Matthew Bishop <ma...@thebishops.org> wrote:
I'm looking at supporting the HAL format for an existing hypermedia API that uses a 'zoom' or 'expand' query parameter to embed related links in a single request. This means the client decides what to embed, and the server does the actual embedding. It all happens in a single request, not with multiple requests like Traverson does.

Has anyone seen / implemented this kind of functionality with a HAL API? I am seeing if the query parameter has been figured out already, and if anyone has written a server-side embedding engine to perform the actual work on the server.

--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-craft+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/api-craft.
For more options, visit https://groups.google.com/d/optout.

Erik Terpstra

unread,
Sep 7, 2016, 2:08:36 AM9/7/16
to api-...@googlegroups.com, Jurriaan Pruis
Also see this blog post: http://nocarrier.co.uk/expanding-zoom/

And this Elixir implementation of a 'zooming proxy' similar to the one we use at blendle.com (written by my colleague Jurriaan Pruis):

--Erik

Op wo 7 sep. 2016 om 03:03 schreef Michael Tiller <michael...@gmail.com>:
To unsubscribe from this group and stop receiving emails from it, send an email to api-craft+...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-craft+...@googlegroups.com.

Matthew Bishop

unread,
Sep 9, 2016, 6:51:27 PM9/9/16
to API Craft, jurr...@blendle.com
Thanks for the links everyone!

Matthew Bishop

unread,
Sep 9, 2016, 6:58:00 PM9/9/16
to API Craft
Mike, JSON-API has a simple query language that would be a good starting point. See http://jsonapi.org/format/#fetching-includes.
To unsubscribe from this group and stop receiving emails from it, send an email to api-craft+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages