A true restful API has been called many things, hypermedia web APIs, ‘the rest of REST’, HATEOAS – the world’s worst acronym, or perhaps the newest hAPIs. Regardless of what you call it, this concept has long been proclaimed to solve nearly all of your most difficult design problems when building a web service interface. There is plenty of evidence to support the claims made by hypermedia evangelists over the years, however one glaring omission is likely the cause for the slow adoption of hypermedia on restful services. How do you consume this service, and what do all of these link relations mean? Building an effective hypermedia client is more complex a task than consuming a CRUD API, an extremely difficult question to answer has been when do the benefits outweigh the cost of complexity? Once past this hurdle, how does a consumer know how to interact with the service?
It is no wonder adoption of a superior design is so slow when a more complex design leads to more complex clients. The primary selling points for this style are longevity, scalability, and flexibility, however the benefit from these traits is seen over a long period of time making the complexity a difficult tradeoff to evaluate at the start.
We are all very familiar with good, seemingly simple hypermedia clients. In fact, you are likely using your favorite one right now to read this. If we know so much about building good hypermedia clients, why are hypermedia APIs still not the de facto standard?
The key to enabling adoption of hypermedia APIs is very simple, make them easier to consume. The Open API Initiative through the swagger specification has demonstrated the power and appeal of standard formats to enable rapid adoption of best practices in accelerated development cycles. I often will call out the shortcomings of the specifications, but it is critical to understand the cause of the successful proliferation to the web at large. The trick is to apply the lessons learned from this success to driving the adoption of semantic hypermedia. To make a hypermedia API easier to consume you create generic clients to encapsulate the complexity by establishing and adhering to a strict http behavior profile. Then you subscribe to or publish a semantic profile of the application adding domain boundaries to the messages and actions. Finally, allowing clients to tailor their hypermedia through requested goals of supported interaction chains.
Often hypermedia is used to augment CRUD services using binding formats like OAS. In this scenario it simply can’t be relied on to drive the interaction with the service as it has no guaranteed, or an unbounded, range of responses. Establishing a range for the hypermedia domain semantics is critical to transition the role of hypermedia from augmentation to the vehicle for application state and resource capabilities.
The takeaway here is simple, if you want to have the robust flexibility offered by hypermedia APIs then your focus should be on enabling strong generic hypermedia clients. To build strong generic hypermedia clients, you need to adhere to strict service behavioral profiles to isolate the domain from the underlying protocol behavior.