Reputation: 2014
What is a discovery based REST API?
From what i can understand from this reference https://en.wikipedia.org/wiki/HATEOAS a discovery based REST API always give a link to the next possible action or actions within the response.
As shown in the article, this below example is a response to a HTTP GET request. I can see that the below code have several different options attached, like deposit, withdraw, transfer and close.
<?xml version="1.0"?>
<account>
<account_number>12345</account_number>
<balance currency="usd">100.00</balance>
<link rel="deposit" href="http://somebank.org/account/12345/deposit" />
<link rel="withdraw" href="http://somebank.org/account/12345/withdraw" />
<link rel="transfer" href="http://somebank.org/account/12345/transfer" />
<link rel="close" href="http://somebank.org/account/12345/close" />
</account>
So is a discovery based REST API really just all about that the response "ALSO" gives the different posibilities there is in the system (ofc only the logical ones to mention in the correct order) ?
Upvotes: 3
Views: 209
Reputation: 1456
Yes, you are correct: in that system for that particular resource.
Imagine in your example the balance is 0 USD and bank policy states you cannot withdraw money without a positive balance. The "withdraw" link would be absent from the list of options.
Upvotes: 2