Skip to content

What is halchemy? ​

Halchemy is a library you use to create client applications - applications that call APIs which use Hypermedia Application Language (HAL).

HAL is an addition to JSON. It is JSON with links[1]. This combines the data your client needs to know about a resource with links to other related resources, or links to operate the resource itself.

Here is an example of a customer resource, represented in HAL:

json
{
    "customerId": "A375",
    "givenName": "John",
    "familyName": "Doe",
    "active": false,
    "_links": {
        "self": {
            "href": "/customers/662fbf1eb5442453d30e4d7a"
        },
        "orders": {
            "href": "/customers/662fbf1eb5442453d30e4d7a/orders"
        },
        "activate": {
            "href": "/customers/662fbf1eb5442453d30e4d7a/activate",
            "method": "PUT",
            "_note": "PUT (with no body) to active this customer"
        }
    }
}

How halchemy helps ​

Let's say your client did a GET request and the above JSON is now in a variable named customer.

With this customer in hand, you may want to:

  • POST an order for this customer
  • GET the orders this customer has made
  • update the customer's name
  • activate the customer
  • print the customer's name

In a hypermedia application, each of these operations is done by following a link. Let's look at how halchemy improves your client code. These examples only scratch the surface of how halchemy helps.

POST an order ​

GET the orders ​

Update the given name ​

Activate the customer ​

These are only a few examples of how halchemy lets your client application more easily make full use of your HAL-based API.

Further reading ​


[1] HAL adds links to JSON (application/hal+json) and to XML (application/hal+xml). Halchemy only works with the JSON flavour of HAL.

Released under the MIT License.