title: Flexibility of HATEOAS
body: <p>I am trying to learn how to better craft REST API, I have read about HATEOAS, but cannot fully understand all flexibility of it. </p>
  
  <p>Can someone explain why is it flexible.</p>
  
  <p>Lets consider PayPal HATEOAS API</p>
  
  <p>Here an example of array of links </p>
  
  <pre><code>[
    {
      "href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-6RV70583SB702805EKEYSZ6Y",
      "rel":"self",
      "method":"GET"
    },
    {
      "href":"https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&amp;token=EC-60U79048BN7719609",
      "rel":"approval_url",
      "method":"REDIRECT"
    },
    {
      "href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-6RV70583SB702805EKEYSZ6Y/execute",
      "rel":"execute",
      "method":"POST"
    }
  ]
  </code></pre>
  
  <p>I understand that we can make a request, for instance in case of this example for payment information.</p>
  
  <p>There are some questions </p>
  
  <ol>
  <li><p>Why do we need <code>self</code> as type of <code>rel</code>, when request is made by the application it already knows the full url of this resource , am I right ? Why do we need to duplicate it in links array ?</p></li>
  <li><p>Whee is flexibility ? In this example there are three (two without self) <code>rel</code> types. How does application know all this types ? They should be hardcoded anyway in code and if for example new <code>rel</code> type was introduced we still need to add logic into the client code to handle such type of <code>rel</code>, so as a result we need to handle types of <code>rel</code> or if API responses doesn't follow HATEOAS principle write logic to make new requests. </p></li>
  </ol>
  
  <p>Am I wrong ?</p>
  
  <p>Please explain the main idea of this. I would be grateful for any help.<br>
  Thank you.</p>