liveBook · Manning

Hypertext link

As explained in Spring in Action, Sixth Edition

A hypermedia link is a response-provided reference that identifies a related resource or available API action.

A hypertext link is a response-provided reference to a related resource or available API action. In Spring Data REST responses, these links implement HATEOAS and can guide clients through an API without hard-coding every URL. section 7.2

Links in an ingredients response

A GET request to /ingredients can return each ingredient with self and ingredient links, plus collection-level self and profile links. A client may follow a named link for its next request. section 7.2

$ curl localhost:8080/ingredients
{
  "_embedded" : {
    "ingredients" : [ {
      "name" : "Flour Tortilla",
      "type" : "WRAP",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/ingredients/FLTO"
        },
        "ingredient" : {
          "href" : "http://localhost:8080/ingredients/FLTO"
        }
      }
    },
    ...
    ]
  },
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/ingredients"
    },
    "profile" : {
      "href" : "http://localhost:8080/profile/ingredients"
    }
  }
}

Inspect the Spring Data REST response structure, including embedded resources and _links containing href values. section 7.2

Hypertext links balance convenience with cost:

  • They let clients discover API navigation from responses instead of constructing every URL themselves. section 7.2
  • They add payload data and require clients to understand link-based navigation, so clients may ignore them. section 7.2

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains HATEOAS navigation, generated response links, and trade-offs, but stops short of implementing custom links.
Examples
Demonstrates ingredient collection and item responses containing self, ingredient, and profile links.
What it assumes
Assumes familiarity with HTTP requests and REST endpoints while introducing HATEOAS and response-based API navigation.
What you can do after
Evaluate whether clients should follow, ignore, or omit HATEOAS links when designing or consuming an API.
How it connects
Connects hypertext links with HATEOAS, Spring Data REST, Spring HATEOAS, REST APIs, and API clients.

Also explained in

Compare how 9 books explain hypertext link →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.