Hypertext Application Language
Hypertext Application Language (HAL) is a lightweight media type format designed to provide a standardized way of expressing hyperlinks and embedded resources within JSON or XML representations of API responses, enabling the creation of self-descriptive and navigable hypermedia-driven APIs.[1] Developed by software engineer Mike Kelly and first released in July 2011, HAL addresses the challenges of API evolution by decoupling client-server coupling through hypermedia controls, allowing clients to discover available actions dynamically without hardcoded URLs.[2][1]
HAL establishes conventions for structuring API resources as Resource Objects, which consist of a primary data payload alongside reserved properties for hyperlinks (_links) and embedded sub-resources (_embedded).[3] The _links property contains an object of link relations (e.g., self, next, or custom rel values) pointing to related resources via target URIs, while _embedded allows nesting of full Resource Objects to avoid additional requests.[3] This structure supports features like URI Templates for parameterized links and Compact URIs (CURIEs) for compact, documentation-linked relation names, enhancing API discoverability.[3] The format's media types are application/hal+json for JSON and application/hal+xml for XML, with the JSON variant being the most widely implemented.[1][3]
Originally created to improve developer experience in a client project requiring flexible URL changes, HAL evolved from a proprietary solution into an open specification through community feedback on the HAL Discuss mailing list.[2] Its first IETF Internet-Draft (draft-kelly-json-hal-00) was published in June 2012, with the latest revision (draft-kelly-json-hal-11) issued in October 2023 as an informational document, though it has not yet advanced to RFC status.[4][3] HAL's simplicity—requiring no schema beyond its core conventions—has contributed to its adoption as a dominant hypermedia format, notably in Amazon's AppStream API starting in early 2014 and various open-source libraries for languages like Java, .NET, and Ruby.[2] By prioritizing human-readable links over complex forms or actions, HAL facilitates API exploration via tools like browsers and automated clients, reducing documentation overhead and supporting RESTful principles.[1][2]
Introduction
Definition and Purpose
The Hypertext Application Language (HAL) is a format designed for representing hypermedia within RESTful APIs using JSON or XML, utilizing the media types application/hal+json and application/hal+xml (with the JSON variant being the most widely implemented).[3][1] It establishes conventions for embedding hyperlinks and related metadata directly into resource representations, enabling clients to navigate APIs dynamically without prior knowledge of specific endpoints.[1]
The primary purpose of HAL is to standardize the structure of resources, links, and metadata in API responses, thereby facilitating the Hypermedia as the Engine of Application State (HATEOAS) principle central to REST architecture.[3] By providing a consistent framework for hypermedia controls, HAL allows API consumers to discover and traverse available actions through links, reducing the need for custom client-side logic or domain-specific implementations.[2]
Unlike plain JSON, which offers flexibility but no inherent semantic structure for hyperlinks or extensibility, HAL imposes lightweight conventions to enhance discoverability and interoperability across services.[5]
Key Features
HAL enables self-descriptive messages by incorporating hyperlinks and embedded resources within JSON or XML representations, allowing clients to navigate and understand API structures without prior knowledge of specific endpoints. The _links property contains an object of link objects, each with a href for the target URI and an optional rel for the relationship type, while the optional _embedded property nests full resource representations to avoid additional requests. This structure supports the HATEOAS principle by making responses navigable through hypermedia controls.[1][6]
A core feature is the use of standardized link relations, such as those registered with the IANA, to enhance discoverability and interoperability across APIs. Link relations serve as identifiers for the semantics of connections between resources, enabling generic clients to interpret actions like "next" for pagination or "self" for the current resource without custom logic. For example, a link with rel: "next" points to the subsequent page in a collection, promoting uniform navigation patterns.[1]
HAL's extensibility is achieved through support for custom properties alongside its reserved ones, allowing domain-specific data without violating the format, and CURIEs (Compact URIs) for abbreviating complex link relation namespaces. CURIEs expand prefixed relations (e.g., ea:find) to full URIs defined in a curies template within _links, facilitating versioned and compact representations in large APIs. This mechanism ensures flexibility while maintaining a consistent structure.[1][6]
Media type negotiation is facilitated by the application/hal+json type (or application/hal+xml for XML), which clients request to receive HAL-formatted responses, and profile linking via the profile parameter or Link headers to indicate API versions or constraints. For instance, a response might include a profile URI like https://example.com/api/v1/profile to specify the expected resource shape, enabling safe evolution of APIs over time.[1]
Property constraints emphasize uniformity, such as requiring the root to be a resource object and including an optional _links property for effective navigation in hypermedia-driven APIs, though minimal valid documents can be empty objects. These conventions ensure that even simple responses include mechanisms for discovery, preventing opaque data dumps.[6]
History and Development
Origins and Initial Proposal
The Hypertext Application Language (HAL) was initially proposed by Mike Kelly, a UK-based software engineer and API consultant, in 2011. Kelly released the first version of the specification on June 13, 2011, as a simple, JSON-based format aimed at providing a consistent structure for hypermedia links in RESTful APIs.[7] The proposal was motivated by the need to minimize developer friction caused by frequent API changes, such as evolving URL structures, by leveraging hypermedia to make APIs more evolvable and self-descriptive.[2]
Kelly's work stemmed from observations of fragmented hypermedia practices in early REST APIs, where developers often invented ad-hoc methods for handling links and resource relations, leading to inconsistent and non-explorable designs.[2] To address this, HAL focused on JSON as the foundational format due to its widespread adoption in web services at the time, allowing for straightforward integration without requiring new serialization mechanisms. The initial draft emphasized uniform link handling to support principles like HATEOAS, enabling clients to discover and navigate API resources dynamically, and included the _embedded property for representing related resources directly within a primary resource.[2][7]
The proposal was first shared via a detailed web page on Kelly's site, stateless.co, and quickly gained traction through open discussion. Early feedback came from API design communities, including the hal-discuss Google Group and the REST Discuss mailing list, where contributors like Mike Amundsen and Darrel Miller provided input that refined the core concepts.[1][2] This community engagement led to the draft being hosted on GitHub under the repository mikekelly/hal_specification, fostering further iteration while keeping the focus on simplicity and interoperability. The JSON variant of HAL was registered with IANA as the media type application/vnd.hal+json on July 14, 2011.[5][8]
Evolution and Standardization
The first IETF Internet-Draft for HAL (draft-kelly-json-hal-00) was published on June 6, 2012.[9]
Subsequent community-driven updates further evolved the format, notably the addition of CURIE (Compact URI) support in draft-kelly-json-hal-06 published on October 3, 2013, enabling templated link relations via the curies array for more concise and extensible hypermedia controls in link documentation.[10]
Ongoing maintenance occurs via the official GitHub repository, where API practitioners contribute refinements and issue discussions, with updates continuing through 2023 in the latest Internet Draft (version 11) issued on October 19, 2023; despite this, HAL lacks formal standardization by bodies like the W3C or IETF, remaining an informal specification that has achieved wide de facto adoption in RESTful API design.[5][6]
Design Principles
HATEOAS Integration
HATEOAS, or Hypermedia as the Engine of Application State, is a core constraint of the REST architectural style that enables clients to discover and navigate application states dynamically through hypermedia links provided by the server, rather than relying on hardcoded URLs or out-of-band knowledge.[11] In this model, the server includes hyperlinks in its representations to indicate possible state transitions, allowing clients to interact with the API as if following a web of discoverable resources.[12]
HAL embodies this HATEOAS principle by mandating the inclusion of a _links object in every resource representation, which is an object whose keys are link relation types (e.g., self or next) and whose values are either a single link object or an array of link objects, each specifying a target URI via the href property for navigation.[6] These links support URI templates—parameterized paths marked with templated: true—enabling clients to construct and follow dynamic transitions, such as querying related resources or advancing through paginated collections.[6] By standardizing this structure in JSON, HAL provides a concrete, machine-readable format for hypermedia controls that aligns directly with HATEOAS requirements.[6]
This integration enhances API evolvability, as servers can modify endpoints or introduce new resources without disrupting clients, which discover actions solely through the provided links rather than fixed paths.[6] HAL thus serves as a practical JSON-based implementation of the HATEOAS constraint outlined in Roy Fielding's 2000 dissertation on REST, bridging theoretical architectural principles with interoperable API design.[12]
Resource and Link Modeling
In HAL, a resource is modeled as a JSON object that encapsulates both the domain-specific state of the resource and navigational elements for hypermedia-driven interactions. The object's properties represent the resource's attributes, such as "currency" or "status," while reserved top-level keys "_links" and "_embedded" provide structured access to related resources. The "_links" key holds an object whose keys are link relation types (e.g., "self" or "next") and whose values are either a single link object or an array of link objects, enabling the representation of multiple possible links for a given relation. This structure ensures that resources are self-descriptive, allowing clients to discover and traverse API affordances without prior knowledge of the entire schema.[6]
Link modeling in HAL centers on the link object, a standardized JSON construct that defines hyperlinks with essential attributes for interoperability. Each link object requires an "href" property containing the target URI reference, which may be absolute or relative, and is associated with a relation type via the enclosing key in the "_links" object. Optional attributes include "templated," a boolean indicating whether the "href" employs URI Templates for parameterization (e.g., "/orders{?id}"), and "title," a human-readable string for labeling the link. Additional extensible properties like "type" (media type of the target) can be included to enhance semantics without altering the core model. This approach supports a uniform way to express both navigational and contextual relationships, aligning with RESTful principles by embedding hyperlinks directly within resource representations.[6]
The uniform interface provided by HAL's resource model integrates domain data with navigational metadata, fostering a consistent API experience across diverse services. By colocating resource properties with "_links" and the optional "_embedded" (which mirrors "_links" but embeds full resource objects or arrays thereof under relation keys), HAL enables clients to process responses holistically—extracting state while simultaneously building a graph of accessible endpoints. This combination reduces coupling between client and server, as navigational logic is conveyed through links rather than hardcoded URIs.[6]
HAL's extensibility model allows implementers to incorporate custom namespaces and properties without disrupting parser compatibility, promoting adoption in varied domains. Properties not starting with an underscore are treated as domain-specific extensions, while link relations can use Compact URIs (CURIEs) for namespacing (e.g., "acme:find") to avoid collisions and support versioning. The media type "application/hal+json" further signals this structure, with optional "profile" parameters in HTTP headers or links providing semantic context for extensions. This design ensures backward compatibility and flexibility, as parsers can safely ignore unrecognized elements while leveraging the core linking mechanism.[6]
Specification Details
Core Conventions
The core conventions of the Hypertext Application Language (HAL) establish the fundamental structural requirements for JSON documents to represent hypermedia-driven resources in a consistent manner. Every HAL document must consist of a single root-level Resource Object, which is a JSON object that includes application-specific state properties alongside HAL-specific control properties. This root object is required to contain a "_links" property, an object that holds at least one Link Object—most commonly a "self" relation pointing to the resource's own URI—to enable self-description and navigation.[6]
HAL reserves properties prefixed with an underscore ("_") to avoid conflicts with domain-specific data, ensuring clear separation between resource state and hypermedia controls. The primary such properties are "_links", which maps relation names to either a Link Object or an array of Link Objects, and "_embedded", an optional property for including related Resource Objects inline to reduce API roundtrips. These conventions promote discoverability by standardizing how hyperlinks and embedded content are expressed within JSON.[6][1]
Link Objects within "_links" adhere to strict JSON type constraints: the "href" property must be a string containing a URI (absolute or relative) that identifies the target resource, where the link relation (per the Web Linking standard, RFC 5988) is denoted by the key name in the "_links" object. Additional optional properties like "title" (a string for human-readable labels) or "deprecation" (an optional URI providing further information about the deprecation) may appear but do not alter the core structure. Similarly, "_embedded" must be a JSON object (for single resources) or array (for multiples), where each value is itself a Resource Object conforming to these rules.[6][13]
For error responses, while HAL does not mandate a specific format, some implementations use an "_error" object at the root level to provide details such as error codes and messages, maintaining the hypermedia structure even in failure cases.[14]
Versioning in HAL is handled through profile links, leveraging the "profile" parameter in the media type (e.g., application/hal+json; profile="https://example.com/v1") as defined in RFC 6906 for the 'profile' link relation type.[6][15]
Link Relations and Curies
In HAL, link relations, or "rel" types, serve as semantic identifiers that describe the purpose and target of a link within a resource representation, enabling clients to understand and navigate the API without prior knowledge of specific URIs. These relations are expressed as keys in the _links object, with values being link objects containing at least an href property pointing to the target resource. Common relations draw from the IANA Link Relations registry, such as "self" to reference the current resource itself, "next" and "prev" for sequential navigation in collections, and "item" for individual elements within a set.[3][16]
To manage longer or namespaced relation identifiers, HAL supports Compact URIs (CURIEs), which abbreviate full Internationalized Resource Identifiers (IRIs) into a compact prefix:reference format, such as "ea:admin" where "ea" expands to a base URI for documentation. CURIEs are declared in a special _links entry named "curies", which is an array of objects each specifying a name (the prefix), an href template for expansion (using {rel} as a placeholder), and optionally "templated": true to indicate URI templating. This mechanism allows rel values to reference external documentation, like http://example.com/docs/rels/{rel}, promoting discoverability and avoiding ambiguity in distributed systems.[3][1]
HAL links may incorporate URI templating in the href attribute to support parameterized navigation, following the Level 4 URI Templates specification (RFC 6570), where placeholders like {?id} or {.fields} denote variables to be substituted by clients. For instance, a link with href: "/orders{?id}" and "templated": true enables dynamic querying by filling in the id parameter. This feature enhances flexibility for actions like searching or filtering, while the templated flag signals to clients that expansion is required before following the link.[3]
For custom relations beyond the IANA registry, HAL recommends namespacing via CURIE prefixes to prevent collisions and ensure semantic clarity, such as "acme:widgets" for domain-specific links to widget resources. Guidelines emphasize using descriptive, lowercase names with hyphens for readability, registering novel relations in the IANA registry when they gain broad adoption, and providing documentation through CURIE href templates to explain usage and expected behaviors. This approach maintains interoperability while allowing API designers to extend HAL for proprietary needs.[3][16][1]
Embedded Resources
In HAL, the _embedded property provides a mechanism for including related resources directly within a primary resource representation, thereby reducing the number of HTTP requests required for clients to access associated data while preserving the hypermedia-driven navigation of HATEOAS. This object maps link relation types (as keys) to either a single Resource Object or an array of Resource Objects, each of which must conform to HAL's structure as a valid, self-contained document. Unlike mere links, embedded resources convey both the target URI (via the _links property) and the resource's state (via arbitrary properties), enabling inline access to pertinent details without separate fetches.[3]
Embedded resources follow specific conventions to ensure consistency and interoperability. They must appear as a direct property of the root Resource Object, parallel to _links, and can represent full, partial, or even inconsistent views of the resource available at the target URI—though servers are encouraged to align them closely with the linked representation for reliability. Each embedded item qualifies as a complete HAL document, complete with its own _links and properties, allowing recursive parsing if needed. To maintain document manageability, implementations should limit embedding depth, as excessive nesting can lead to oversized payloads that undermine performance and readability, though the specification does not enforce a strict limit.[3][1]
A common use case for embedding arises in scenarios requiring contextual enrichment, such as including author details within a blog post resource to provide immediate access to metadata without additional queries. For instance, a HAL representation of a post might embed the author's profile as follows:
{
"_links": {
"self": { "href": "/posts/1" },
"author": { "href": "/people/123" }
},
"title": "Sample Post",
"_embedded": {
"author": {
"_links": {
"self": { "href": "/people/123" }
},
"name": "Jane Doe",
"email": "[email protected]"
}
}
}
{
"_links": {
"self": { "href": "/posts/1" },
"author": { "href": "/people/123" }
},
"title": "Sample Post",
"_embedded": {
"author": {
"_links": {
"self": { "href": "/people/123" }
},
"name": "Jane Doe",
"email": "[email protected]"
}
}
}
This approach delivers the author's essential state inline, streamlining client-side rendering or processing.[3]
Embedding strikes a balance between API efficiency and adherence to HATEOAS principles, as it optimizes for reduced latency in common navigation paths (e.g., via hypertext caching patterns) while mandating that full navigational links remain present for clients that ignore or cannot process embeds. Servers should embed resources using the same relation types as their corresponding links, ensuring that even non-supporting clients can discover and follow them independently, thus avoiding any dilution of the hypermedia controls essential to discoverability. This trade-off supports performance gains in bandwidth-constrained environments without compromising the API's self-descriptive nature.[3]
Practical Examples
Basic Resource Representation
In HAL, a basic resource representation consists of a JSON object that encapsulates the resource's state through standard properties, while hyperlinks to related resources are provided via the reserved _links property. This structure adheres to the core conventions of the JSON Hypertext Application Language specification, enabling clients to navigate APIs without prior knowledge of specific URIs.[3]
A typical example occurs in an HTTP response to a retrieval request for a single resource. For instance, a GET request to /users/123 with the Accept: application/[hal](/page/Hal)+[json](/page/JSON) header yields a 200 OK response with Content-Type: application/[hal](/page/Hal)+[json](/page/JSON). The body represents a user resource as follows:
json
{
"_links": {
"self": { "href": "/users/123" },
"profile": { "href": "/profiles/123" }
},
"id": "123",
"name": "John Doe"
}
```[](https://www.ietf.org/archive/id/draft-kelly-json-hal-11.html)
Here, the properties `id` and `name` hold the domain-specific data of the resource, conveying its essential attributes in plain JSON format. The `_links` object, a required element for hypermedia, contains link objects keyed by relation types such as `self` and `profile`; each link includes an `href` property specifying the target URI. The `self` link particularly ensures the resource's unique identity, allowing clients to reference or bookmark it independently.[](https://www.ietf.org/archive/id/draft-kelly-json-hal-11.html)
HAL parsers process this representation by first extracting the resource's properties for display or manipulation, then traversing the `_links` object to discover available actions, such as following the `profile` relation to access additional details. This link extraction follows standardized relation types defined in RFC 5988, promoting uniform navigation across HAL-compliant APIs.[](https://www.ietf.org/archive/id/draft-kelly-json-hal-11.html)[](https://www.rfc-editor.org/info/rfc5988)
### Collection and Pagination Example
In HAL, collections of resources are typically represented as a primary resource containing an [array](/page/Array) of [embedded](/page/Embedded) items under the `_embedded` [key](/page/Key), allowing clients to access related data without additional requests. Each [embedded](/page/Embedded) item functions as its own [resource](/page/Resource) object, complete with its own `_links` for [navigation](/page/Navigation), such as a `self` [relation](/page/Relation) pointing to the individual item's [URI](/page/Uri). This structure supports efficient representation of lists, like orders in an [e-commerce](/page/E-commerce) [API](/page/API), while maintaining hypermedia principles.[](https://stateless.group/hal_specification.html)[](https://www.ietf.org/archive/id/draft-kelly-json-hal-11.html)
Pagination in HAL collections is handled through navigational links in the top-level `_links` object, using standard relation types to enable clients to traverse pages without hardcoding offsets or limits. Common relations include `first` for the initial page, `last` for the final page, `next` for the subsequent page, and `prev` for the previous page, each with an `href` attribute specifying the URI. These links often incorporate query parameters like `?page=2` to indicate the current position in the sequence. For instance, a paginated collection might include metadata such as `count` for items on the current page and `total` for the overall number of resources.[](https://apigility.org/documentation/api-primer/halprimer)[](https://stateless.group/hal_specification.html)
The following JSON example illustrates a paginated collection of orders, with embedded order items and full pagination links:
```json
{
"_links": {
"self": { "href": "http://example.com/orders?page=1" },
"first": { "href": "http://example.com/orders" },
"next": { "href": "http://example.com/orders?page=2" },
"last": { "href": "http://example.com/orders?page=10" }
},
"count": 2,
"total": 20,
"_embedded": {
"orders": [
{
"_links": {
"self": { "href": "http://example.com/orders/123" }
},
"orderId": 123,
"total": 30.00,
"status": "shipped"
},
{
"_links": {
"self": { "href": "http://example.com/orders/124" }
},
"orderId": 124,
"total": 20.00,
"status": "processing"
}
]
}
}
{
"_links": {
"self": { "href": "/users/123" },
"profile": { "href": "/profiles/123" }
},
"id": "123",
"name": "John Doe"
}
```[](https://www.ietf.org/archive/id/draft-kelly-json-hal-11.html)
Here, the properties `id` and `name` hold the domain-specific data of the resource, conveying its essential attributes in plain JSON format. The `_links` object, a required element for hypermedia, contains link objects keyed by relation types such as `self` and `profile`; each link includes an `href` property specifying the target URI. The `self` link particularly ensures the resource's unique identity, allowing clients to reference or bookmark it independently.[](https://www.ietf.org/archive/id/draft-kelly-json-hal-11.html)
HAL parsers process this representation by first extracting the resource's properties for display or manipulation, then traversing the `_links` object to discover available actions, such as following the `profile` relation to access additional details. This link extraction follows standardized relation types defined in RFC 5988, promoting uniform navigation across HAL-compliant APIs.[](https://www.ietf.org/archive/id/draft-kelly-json-hal-11.html)[](https://www.rfc-editor.org/info/rfc5988)
### Collection and Pagination Example
In HAL, collections of resources are typically represented as a primary resource containing an [array](/page/Array) of [embedded](/page/Embedded) items under the `_embedded` [key](/page/Key), allowing clients to access related data without additional requests. Each [embedded](/page/Embedded) item functions as its own [resource](/page/Resource) object, complete with its own `_links` for [navigation](/page/Navigation), such as a `self` [relation](/page/Relation) pointing to the individual item's [URI](/page/Uri). This structure supports efficient representation of lists, like orders in an [e-commerce](/page/E-commerce) [API](/page/API), while maintaining hypermedia principles.[](https://stateless.group/hal_specification.html)[](https://www.ietf.org/archive/id/draft-kelly-json-hal-11.html)
Pagination in HAL collections is handled through navigational links in the top-level `_links` object, using standard relation types to enable clients to traverse pages without hardcoding offsets or limits. Common relations include `first` for the initial page, `last` for the final page, `next` for the subsequent page, and `prev` for the previous page, each with an `href` attribute specifying the URI. These links often incorporate query parameters like `?page=2` to indicate the current position in the sequence. For instance, a paginated collection might include metadata such as `count` for items on the current page and `total` for the overall number of resources.[](https://apigility.org/documentation/api-primer/halprimer)[](https://stateless.group/hal_specification.html)
The following JSON example illustrates a paginated collection of orders, with embedded order items and full pagination links:
```json
{
"_links": {
"self": { "href": "http://example.com/orders?page=1" },
"first": { "href": "http://example.com/orders" },
"next": { "href": "http://example.com/orders?page=2" },
"last": { "href": "http://example.com/orders?page=10" }
},
"count": 2,
"total": 20,
"_embedded": {
"orders": [
{
"_links": {
"self": { "href": "http://example.com/orders/123" }
},
"orderId": 123,
"total": 30.00,
"status": "shipped"
},
{
"_links": {
"self": { "href": "http://example.com/orders/124" }
},
"orderId": 124,
"total": 20.00,
"status": "processing"
}
]
}
}
This example shows two embedded orders, each with a self link for direct access, embedded within a collection that provides navigation across 10 total pages of 20 orders.[17][1]
For dynamic querying, HAL supports templated links in collections, where the href uses URI templates (per RFC 6570) and the templated property set to true to indicate parameter substitution. This allows clients to filter or sort the collection, such as retrieving orders by status via /orders{?status}. An example link might appear as "search": { "href": "/orders{?status}", "templated": true }, enabling expansions like /orders?status=shipped for targeted pagination.[3]
Implementations and Ecosystem
Client-Side Libraries
Client-side libraries for Hypertext Application Language (HAL) enable developers to parse, navigate, and interact with HAL-formatted resources in applications, facilitating the consumption of hypermedia-driven APIs without hardcoding endpoints. These tools typically handle the extraction of links by relation types, support for embedded resources, and traversal of resource graphs, aligning with HAL's emphasis on discoverability.
In the JavaScript ecosystem, Traverson serves as a prominent library for following HAL links in both Node.js and browser environments, allowing asynchronous navigation through relations like "self" or "next" to fetch related resources dynamically. Halson provides utilities for constructing and manipulating HAL resource objects, including methods to add links and embedded data while validating against HAL conventions. More recent options, such as @contentgrid/hal, offer type-safe representations of HAL JSON for modern TypeScript projects, updated as late as March 2025.[18]
For Java, Spring HATEOAS incorporates client-side features through its Traverson API, which enables link traversal and data extraction via fluent methods, such as following a chain of relations to retrieve nested object properties. The library's HalLinkDiscoverer component parses _links sections to identify relations efficiently, integrating seamlessly with Spring's WebClient or RestTemplate for HTTP interactions. These tools support templated links with parameter substitution, enhancing flexibility in API consumption.[19]
In Python, the Halogen library supports both parsing incoming HAL JSON into navigable objects and generating outgoing representations, with built-in handling for CURIE expansion and validation of required HAL elements like _links and _embedded. It allows building resource graphs declaratively, making it suitable for scripting API interactions or integrating with frameworks like Flask.[20]
Common features across these libraries include automatic URI resolution by dereferencing links via HTTP clients, CURIE expansion to resolve abbreviated relation URIs, and error handling for cases like missing relations or invalid media types, which promote robust client implementations. As of 2025, active maintenance continues in key ecosystems; for instance, Spring HATEOAS documentation reflects updates through November 2025, while .NET's HAL.Client.Net library, last updated in June 2024, provides support for HAL consumption though it is no longer actively maintained. In Node.js, packages like @contentgrid/hal demonstrate sustained development for frontend and backend use cases.
Spring HATEOAS is a module within the Spring Framework that simplifies the creation of HAL-compliant REST representations, particularly for Spring MVC applications. It provides builder APIs such as RepresentationModel and EntityModel to construct resources with _links and _embedded sections directly from domain models, enabling developers to add hypermedia controls like self-referential links and related resource embeddings without manual JSON serialization.[19] This approach integrates seamlessly with Spring Boot's auto-configuration for hypermedia-driven APIs, supporting features like link relations via RelProvider and content negotiation for application/hal+json media type.[21]
In Node.js environments, libraries like express-hal offer middleware to generate HAL responses in Express.js applications. It exposes a res.hal method that assembles JSON-HAL bodies from resource objects, automatically handling link arrays and embedded resources while supporting templating for dynamic URIs.[22] Although originally released in 2012, it remains available via npm and can be integrated into modern Express setups for basic HAL rendering, though developers may extend it for current Node.js versions.[23]
For Ruby-based APIs, Grape supports HAL output through extensions like grape-roar, which leverages the Roar gem to render hypermedia representations. This integration allows API builders to define entities with HAL-specific formatters, automatically generating _links from route helpers and embedding related objects while maintaining Grape's lightweight DSL for endpoint definitions.[24] The grape-roar adapter ensures compliance with HAL conventions by mapping Ruby objects to the required JSON structure, facilitating hypermedia in Rack-mounted services.
Tooling for server-side HAL development includes the HAL Explorer, a web-based viewer for testing and visualizing API endpoints. This Angular application fetches HAL responses, renders navigable links, and supports form interactions via HAL-FORMS, allowing developers to verify resource structures and hypermedia controls during implementation.[25] Updated as of March 2025, it provides an interactive interface for exploring embedded resources and link relations without custom client code.[26]
Compliance with HAL specifications up to version 1.0 (stable since 2014, with extensions like HAL-FORMS in 2025 drafts) can be ensured using validators integrated into frameworks or standalone tools. For instance, Spring HATEOAS includes built-in assertions for link validity and media type adherence, while libraries like grape-roar validate output against the HAL JSON schema during rendering.[19] Additionally, the HAL-FORMS profile, as implemented in tools like Dwolla's hal-forms, adds form validation metadata to resources, helping servers check submitted data against embedded schemas for spec-conformant interactions.[27]
Comparisons and Alternatives
HAL vs. JSON API
Hypertext Application Language (HAL) and JSON API are both JSON-based formats designed to enable hypermedia-driven APIs that adhere to the HATEOAS principle, allowing clients to discover available actions through links embedded in responses.[3][28] However, HAL adopts a minimalist approach, primarily enhancing plain JSON with conventions for hyperlinks and resource embedding, without prescribing broader API behaviors such as pagination or error handling.[3] In contrast, JSON API provides a more comprehensive and opinionated specification that standardizes resource serialization, including structured support for compound documents, sparse fieldsets, and errors, resulting in a heavier but more prescriptive framework.[28]
HAL's core strength lies in its simplicity, using the _links object to represent relations like "self" or "next" and the _embedded object for including related resources inline, which keeps the format lightweight and flexible for custom implementations.[3] It lacks built-in mechanisms for pagination—relying instead on ad-hoc links—or standardized error responses, leaving these to HTTP conventions or application-specific extensions.[3] JSON API, on the other hand, enforces a rigid structure with mandatory type and id fields in resources, alongside attributes for data and relationships for links, enabling features like sparse fieldsets (where clients request only needed fields via query parameters) and compound documents that bundle related resources in an included array to minimize round trips.[28] It also defines a standardized error format with objects containing status, title, and detail fields, promoting consistency across implementations.[28]
The trade-offs between the two highlight their suitability for different scenarios: HAL's minimalism makes it easier to integrate into existing JSON APIs for custom hypermedia needs, reducing overhead in smaller or evolving projects, but it can lead to inconsistencies in large teams without additional conventions.[29] JSON API excels in enforcing uniformity and reducing client-server negotiation through its detailed spec, making it preferable for collaborative environments or complex ecosystems, though its verbosity and strict rules may complicate adoption in simpler use cases.[29][30]
In terms of interoperability, both formats support HATEOAS by providing discoverable links, but they diverge in embedding strategies—HAL's _embedded allows direct nesting of full or partial resources, while JSON API's included section separates top-level resources from sideloaded ones to avoid duplication and support polymorphic relations.[3][28] This difference can affect client parsing logic, with HAL offering more straightforward nesting at the cost of potential redundancy, and JSON API prioritizing normalization for efficiency in data-heavy responses.[29]
Hypertext Application Language (HAL) and Siren represent two distinct approaches to hypermedia in JSON-based APIs, with HAL emphasizing a lightweight structure built on standard JSON objects and arrays, while Siren introduces more expressive elements for entity representation and interactions. In HAL, resources are expressed as JSON objects containing arbitrary properties alongside dedicated _links and _embedded members for navigation and inline resources, respectively, promoting a simple extension of plain JSON without requiring additional semantics.[1] In contrast, Siren structures responses around entities that include class for semantic classification, properties for data, entities for sub-resources, links for navigation, and notably actions that define RPC-like operations with specified HTTP methods, fields, and types, enabling clients to discover and invoke complex interactions directly from the representation.[31] This difference highlights HAL's focus on basic hyperlinking versus Siren's provision for form-like actions that guide client behavior more explicitly.
Compared to other hypermedia formats, HAL's design aligns closely with everyday JSON usage, differing from Collection+JSON, which is narrowly tailored for managing collections through a root collection object containing version, href, an items array for resources, queries for search capabilities, and a template for additions or updates, but lacks broad support for individual resource representations or embedding.[32] Similarly, JSON-LD prioritizes semantic web interoperability by incorporating @context to map JSON keys to RDF vocabularies, facilitating linked data serialization with implicit hypermedia via properties like @id and @type, though it introduces additional complexity for non-semantic API use cases.[33]
HAL's primary strength lies in its simplicity and minimal overhead, allowing seamless integration with existing JSON tooling and reducing verbosity in representations, which contrasts with Siren's richer action model that supports detailed input validation and method specification but can result in more structured, potentially heavier payloads.[29] HAL's native alignment with JSON also contributes to its advantages in verbosity over formats like JSON-LD, which requires context definitions that expand documents for semantic precision. Regarding ecosystem support, HAL benefits from broader tooling availability, including libraries in frameworks like Spring HATEOAS, due to its straightforward JSON conventions that leverage general-purpose parsers without format-specific overhead.[29]
Adoption and Impact
Notable Use Cases
One notable use case of HAL is in the Amazon API Gateway, where it serves as the hypermedia format for resource-based APIs, enabling standardized linking between API resources to facilitate navigation and discoverability in serverless architectures.[34]
Adidas employs HAL in its REST API guidelines to provide consistent hyperlinking between resources, ensuring that API responses include embedded links for related endpoints, which supports scalable integration across their e-commerce and internal services.[35]
A practical case study in the banking sector involves Dwolla's payment API, which leverages JSON-HAL to embed forms and links in responses, enabling clients to evolve independently—such as updating payment flows or integrating new verification steps—without requiring server-side redeployments, thus reducing maintenance overhead in financial transactions.[36]
Benefits and Criticisms
One key benefit of HAL is its promotion of loose coupling between clients and servers, as links provided in responses allow clients to discover and navigate resources dynamically without hardcoding URLs, enabling independent evolution of API versions and reducing breakage during maintenance updates.[37] This approach facilitates easier maintenance, since changes to server-side resource locations or structures can be propagated through updated links rather than requiring client redeployments.[37] Additionally, HAL's lightweight design—relying on simple conventions like _links and _embedded properties atop standard JSON—avoids the overhead of comprehensive schemas, making it simpler to implement and parse compared to more rigid formats.[7] As of November 2025, HAL continues to see support in frameworks such as Spring HATEOAS, contributing to its role in hypermedia-driven APIs.[19]
Despite these advantages, HAL's informal specification has drawn criticism for leading to inconsistent implementations across tools and libraries, as the lack of strict enforcement allows variations in how links and embeddings are handled, complicating interoperability.[38] Critics also note limited built-in support for error handling, with the format focusing primarily on resource representation rather than standardized mechanisms for conveying detailed error contexts or recovery options, often requiring custom extensions. Furthermore, HAL is not well-suited for complex, GraphQL-style queries that demand fine-grained data selection, as its hypermedia-driven navigation encourages sequential resource discovery over batched or relational fetches.[38]
Adoption gaps persist due to competition from more mature alternatives like OpenAPI (formerly Swagger), which offer superior tooling for documentation, validation, and client generation, overshadowing HAL's hypermedia focus in many enterprise settings.[39] Performance concerns, such as added payload size from embedded resources and links, can introduce parsing overhead, particularly in resource-constrained environments, contributing to HAL's underuse relative to schema-based APIs.[40]