10 Hateoas Design Patterns
DodaTech
1 min read
title: HATEOAS Design Patterns for Hypermedia APIs weight: 20 date: 2026-06-28 lastmod: 2026-06-28 description: Learn HATEOAS design patterns including conditional links based on state, pagination with next/prev links, action forms, and embedding related resources for navigable APIs. tags: [api-development, hateoas]
HATEOAS design patterns include conditional links that appear or disappear based on resource state, pagination with prev/next/first/last links, action forms with method and schema hints, and embedded resources for reducing round trips.
```python
def build_order_response(order):
response = {
"id": order.id,
"status": order.status,
"total": order.total,
"_links": {"self": {"href": f"/orders/{order.id}"}}
}
# Conditional links based on state
if order.status == "pending":
response["_links"]["pay"] = {
"href": f"/orders/{order.id}/payment",
"method": "POST",
"schema": {"amount": {"type": "number"}}
}
response["_links"]["cancel"] = {
"href": f"/orders/{order.id}",
"method": "DELETE"
}
elif order.status == "paid":
response["_links"]["refund"] = {
"href": f"/orders/{order.id}/refund",
"method": "POST"
}
elif order.status == "shipped":
response["_links"]["track"] = {
"href": f"/orders/{order.id}/tracking",
"method": "GET"
}
return response
What's Next
Now learn about Temple payload in Hypermedia APIs and HATEOAS.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro