Skip to main content
Version: 7.5.x

Using Zoom In Client Applications

Cortex uses hypermedia links to associate related resources together. Client applications need to make multiple requests to retrieve information from a resource’s links. Using zoom, you can retrieve all these links with a single request. When a request uses zoom, Cortex retrieves all the requested links and generates a single response containing the linked data. All links that can be retrieved can also be "zoomed".

Example Using zoom​

In this example, zoom retrieved the cart resource and its corresponding lineitems and total resources. Once the client application receives the response, JSONPath can extract the data you’re interested in.

{
"self": {
"type": "elasticpath.carts.cart",
"uri": "/carts/mobee/guz=?zoom=lineitems,total",
"href": "http://api.elasticpath.net/cortex/carts/mobee/guz=?zoom=lineitems,total"
},
"total-quantity": 3,
"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/cortex/totals/carts/mobee/guz="

}
],

"_lineitems": [
{
"self": {
"type": "elasticpath.collections.links",
"uri": "/carts/mobee/guz=/lineitems",
"href": "http://api.elasticpath.net/cortex/carts/mobee/guz=/lineitems"
},
"links": [
{
"rel": "element",
"rev": "list",
"type": "elasticpath.carts.line-item",
"uri": "/carts/mobee/guz=/lineitems/hfq=",
"href": "http://api.elasticpath.net/cortex/carts/mobee/guz=/lineitems/hfq="
},
{
"rel": "element",
"rev": "list",
"type": "elasticpath.carts.line-item",
"uri": "/carts/mobee/guz=/lineitems/gbq=",
"href": "http://api.elasticpath.net/cortex/carts/mobee/guz=/lineitems/gbq="
},
{
"rel": "cart",
"rev": "lineitems",
"type": "elasticpath.carts.cart",
"uri": "/carts/mobee/guz=",
"href": "http://api.elasticpath.net/cortex/carts/mobee/guz="
}
]
}
],
"_total": [
{
"self": {
"type": "elasticpath.totals.total",
"uri": "/totals/carts/mobee/guz=",
"href": "http://api.elasticpath.net/cortex/totals/carts/mobee/guz="
},
"cost": [
{
"amount": 211,
"currency": "CAD",
"display": "$211.00"
}
],
"links": [
{
"rel": "cart",
"rev": "total",
"type": "elasticpath.carts.cart",
"uri": "/carts/mobee/guz=",
"href": "http://api.elasticpath.net/cortex/carts/mobee/guz="
}
]
}
]
}

Extract total-quantity child property​

JSONPath: $total-quantity

Result:

[
3
]

Extract every quantity value nested in other properties​

JSONPath: $..quantity

Result:

[
2,
1
]

Extract first element of total cost array​

JSONPath: $_total..cost[0]

Result:

[
{
"amount": 211,
"currency": "CAD",
"display": "$211.00"
}
]