-1

Option 1:

We always return "absolute" links (no nesting). That way we always give to the client the same link for a given resource.

{
    "employeeName": "Joe"
    "links": {
        "company": [
            { "href": "http://api.com/companies/1" }
        ]
}

Is it needed? (knowing that it requires extra work on the server side)

Option 2:

We may also return "relative" links, nested under the resource returned to the client (here employee). But now the client may have received 2 differents links ("http://api.com/companies/1" and "http://api.com/employees/4/company") corresponding to the same resource.

{
    "employeeName": "Joe"
    "links": {
        "company": [
            { "href": "http://api.com/employees/4/company" }
        ]
}

Is there a better option than the other and why?

mb21
  • 34,845
  • 8
  • 116
  • 142
user3408654
  • 301
  • 1
  • 13

1 Answers1

1

It's OK to have multiple links to same resource.

URL design is irrelevant in HATEOAS.

Denis
  • 83
  • 2
  • 14
  • Thanks Denis. Would you mind sharing resources confirming what you are saying? – user3408654 Jan 15 '16 at 09:02
  • 1
    That resource is a book: RESTful Web APIs By Leonard Richardson, Mike Amundsen, Sam Ruby http://shop.oreilly.com/product/0636920028468.do?sortby=publicationDate – Denis Jan 15 '16 at 11:54