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
And the dinners have started #marrigeaftereffects

Fractals and Mandelbrot Set

While mathematics is in itself quite interesting and forms the basis of any modern day research, be it computational biology, machine learning or building complex structure, it can be quite a challenge to decide where to start.  That is why i decided to explore Fractals, thinking of it as a bridge between the nature and science. It brings in some really fascinating concepts which should be good enough for me as a gateway go deeper.  Fractals are in simple language never ending patterns which keep on repeating without an end, because fractals are never ending they have an infinite perimeter but finite area.  Since the patterns repeats indefinitely but if you draw a circle around the peremeter the area will remain finite.  It is like adding 1+0.1+0.01+0.001 and never making 2 This video explains the basic concept really well  Fractals are found everywhere nature in Trees, Rivers, Branching patterns, Hurricanes and Galaxies. It tries to bring order and understanding to the patterns that w