You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Next »

No, this is not a reference to the HAL 9000 from Clarke's 2001: A Space Odyssey,

Quick Answer

HAL is an acronym for Hypertext Application Language and is designed to provide "...a set of conventions for expressing hyperlinks in either JSON or XML." HAL is an IANA registered media type that enables RESTful APIs to return JSON* content with hypertext (aka hypermedia) that can be easily interpreted by machine and human agents. Because it is a registered media type, developers can specify application/hal+json as the value for the Content-Type response header.

* There is a HAL media type for both JSON and XML. However, we will limit our attention to JSON since that is what the SRP HTTP Framework uses by default.

Digging Deeper

In our What is REST? article we introduced an important aspect of the Uniform Interface constraint known as HATEOAS. The concept of HATEOAS borrows the concept of hyperlinks in HTML to provide self-documented options for users. The difference is that HTML defines this as a standard which makes it possible for clients to interpret the hyperlinks automatically. Plain old JSON does not define hypermedia in any way. This means any hypermedia included in a JSON object has no self-interpreted meaning. Clients cannot know the difference between a URI that is part of the data model (e.g., a property called companyWebSite) versus a URI that clients can use to navigate to another resource.

HAL resolves this by defining how clients should properly identify hypermedia within JSON objects. This is why the SRP HTTP Framework normally sets the Content-Type response header to application/hal+json instead of just application/json.

  • No labels