HATEOAS / HAL Specification
Reference 为 Hypertext Application Language (HAL) 为 embedding hypermedia links 在 JSON responses.
HAL Structure
HAL embeds links in resources using a _links property containing rel-to-link mappings. Each link has an href and optional properties like type, title, or templated. Embedded resources use _embedded with the same rel structure. The format is minimal, adding only two reserved properties to standard JSON. HAL enables HATEOAS: clients discover actions via links rather than hardcoded URLs.
- _links
- Hypermedia links
- _embedded
- Sideloaded resources
- templated
- URI templates
rel -> { href } embedded objects RFC 6570 HATEOAS Principles
HATEOAS (Hypermedia as the Engine of Application State) lets clients navigate APIs via links. The entry point provides initial links; subsequent actions are discovered from responses. This decouples clients from URL structures, enabling API evolution. HAL is one of several hypermedia formats (also Siren, Collection+JSON). The approach improves discoverability and self-documentation at the cost of larger responses.
- discoverability
- Links in responses
- evolution
- API can change URLs
- tradeoff
- Larger responses
no hardcoded URLs clients follow links more navigation