There is currently no standardized way of implementing hypermedia, and many specs have been developed and are even being created as we speak. However, while it’s important to innovate when building your API, it’s also important to adhere to the tools and standards that developers know, and the specifications that have been carefully tried and tested. While it is worthwhile to try specs such as CPHL, Siren, UBER, Yahapi and others in your own personal projects, it is recommended to utilize HAL or JSONAPI for your production API unless you have a strong reason to choose a different specification.
In a nuttshell: HAL and JSONAPI are the most popular. JSON-LD is a W3C standard but was really designed for linking definitions between databases. Collection+JSON was one of the original ones created by Mike Amundsen. Great specification, but less used than HAL or JSON API. Siren is actually really interesting in that it went a different direction. Siren has foreign properties, class properties, and entity properties, and it’s action‑driven like CPHL. Action-driven means that a resource may be included multiple times if necessary (ie edit, delete), but described by its title, description, and the methods it utilizes – making it more explicit than other formats.
A recent draft initiative is HAL-FORMS: it extends HAL with the possibility of capturing ‘templates’ to specify operations over a resource and the inputs of the operations (‘template’ property).
Unfortunately, no hypermedia specification is perfect!
|All formats||Explanation of all formats|
|Kevin Sookocheff I||https://sookocheff.com/post/api/on-choosing-a-hypermedia-format/|
|Kevin Sookocheff II||https://gist.github.com/soofaloofa-zz/9350847|
|Michael Stowe||https://restapilinks.com/wp-content/uploads/2021/01/0.pdf (p.124)|
|Java Code Geeks||https://www.javacodegeeks.com/restful-services-with-hateoas-hypermedia-the-secret-ingredient-of-rest.html|
|Single format||Explanation of a single format|
|HAL – Amazon API Gateway||https://docs.aws.amazon.com/apigateway/api-reference/|
|INNOQ – Pragmatic HAL APIs||https://www.innoq.com/de/articles/2020/12/rest-apis-with-hal/ (HAL extensions to disclose HTTP methods)|
|Misc||Various useful links|
|Converting HAL -> JSON-LD||https://ontola.io/blog/json-hal-ld/|
|Hypermedia Maturity Model||https://8thlight.com/blog/jason-desrosiers/2018/05/30/the-hypermedia-maturity-model.html|
|Kai Tödter’s HAL Explorer||https://github.com/toedter/hal-explorer (An API explorer for RESTful Hypermedia APIs using HAL or HAL-FORMS)|