Skip to main content

HATEOAS - Hypermedia as the Engine of Application State

Just came across this term HATEOAS , which some of my team members were using in describing what we did in our previous project wrt to REST.


My Last project was about building an e-commerce platform for one of the largest book publisher and distributor in Latin America.As part of that project we had thought to use the LEVEL-3 for rest communication which is using REST as a hypermedia controls. 


You can read about different levels of REST at this Martin Fowler’s Blog .


When we said we wanted to use REST as hypermedia controls , the main idea behind this was to be able to navigate the result of a REST call.


For Example if there is a product catalogue call which looks like



GET /products/123456



So It would return 


As you can see that apart from the the properties of the product 123456 it also has a links array.


This links array contains the the link description in rel and the location of that document.


so essentially what i could do is parse the JSON response , and then look for what all things can be done on that product.In this case we have exposed two actions , one for the self and the other to place an order for that product.Then to place an order would be to simple do a post on the the href for rel = “order”


The biggest advantage of this scheme is that , you are not dependent on the uri schemes of API , since every time you are navigating the href , if if the API provider changes the url’s you will not be affected . All you need is an entry point in the API and then you can navigate from there on.


This specifically helps during the development process too , as you can change the routes of the API without worrying about breaking the tests anywhere else .

Comments

Popular posts from this blog

It was a great experience to talk to a huge audience in Mumbai and Delhi about how to start your ML journey at Google Cloud Summit ’18 India

Sunset

Sunset

COVID-19 Lockdown

It is May 11th 2020 and most of India has been under lockdown for 46 straight days. These have been tough times for everyone. While some of the folks i know have been cribbing about being bored to death in this lockdown, for me it has been a busy time. My current field of work which is "Cloud Technology" picked up as everyone was locked up with nothing but technology to entertain and survive and hence there was a lot of work. While me and my family was trying to navigate the chaos and madness of ordering everything online, i would say we were able to deal with the situation without going out much.  This was until my phone broke, crashed, bricked, it was gone.  While i had a spare 4 year old iPhone to fall back on but you know about spare phones, they were too old to trade for a newer one is why you decided to label it as a spare and keep it. They almost never work. So after struggling to get my office and personal stuff to work on an old phone and tablet, i decided i needed t