Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. The Developer Center continues to support Commerce 6.13.0 through 7.4.1.Visit new site

Links

Links

Cortex uses hypermedia links to associate related resources. Links have a relationship name, or rel that defines the relationship a resource has with other resources. Unlike URLs, which may change as the API evolves, these relationship names are stable and will not change. Using rels to link to resources provides the following advantages:
  • New relationships and features added to Cortex do not affect your application. Either use the new links in your application or safely ignore them.
  • A single Cortex can power different types of client applications. Each application can choose to use a different subset of links, which is important for mobile applications as they may not want to display as much detail as a web application.
  • Using rels effectively decouples your client application from Cortex.
Links return in an array with every resource request. The following example shows a cart resource's links array:
"links": [
  {
    "rel": "lineitems",
    "rev": "cart",
    "type": "elasticpath.collections.links",
    "uri": "/carts/mobee/guz=/lineitems",
    "href": "http://api.elasticpath.net/cortex/carts/mobee/guz=/lineitems"
  },
  {
    "rel": "order",
    "rev": "cart",
    "type": "elasticpath.orders.order",
    "uri": "/orders/mobee/mu3=",
    "href": "http://api.elasticpath.net/cortex/orders/mobee/mu3="
  },
  {
    "rel": "total",
    "rev": "cart",
    "type": "elasticpath.totals.total",
    "uri": "/totals/carts/mobee/guz=",
    "href": "http://api.elasticpath.net:8080/cortex/totals/carts/mobee/guz="
  }
]
A link to the resource itself returns with every request. The self link is contained within a self object that describes the retrieved resource. This following example shows a cart resource's self object:
"self": {
  "type": "elasticpath.carts.cart",
  "uri": "/carts/mobee/guz=",
  "href": "http://api.elasticpath.net/cortex/carts/mobee/guz=",
  "max-age": 0
}