OCAPI property selection 19.3

Property selectors reduce the number of resource properties retrieved by the API, so you can get only those properties you care about, while reducing network bandwidth.

You can specify property selectors for all resource types; to do so, you set the select parameter on the request. The actual selector value must be enclosed within parentheses. The following table lists the different capabilities of property selectors for different select parameter values:

Capability Value of select parameter
Include properties of all levels, including complex properties. (**)
Include properties of top level, except complex properties. (*)
Include a single property. (price) (+price)
Exclude a single property. (-price)
Include the child document properties. (variation_attributes.(**))
Return only the first document in array. Index starts with 0. (variation_attributes[0].(**))
Return only the first 5 documents in array. Index starts with 0. (variation_attributes[0:4].(**))
Return only the second, fourth and sixth document in array. Index starts with 0. (variation_attributes[1,3,5].(**))
Return only documents in array that match the filter. Filter expression syntax is '?(boolean_expression)'. Supported Operators: '==', '!=', '<=', '>=', '<', '>' (variation_attributes[?(@.name=='color')].(**))
Filter expression can be OR ('||') and AND ('$amp;&') combined. (variation_attributes[?(@.name=='color' && @.id=='size')].(**))

You can specify a single property name or a comma-separated list of property names enclosed by parentheses. The following example shows how you can select the name, id, and variation_attributes properties of the product resource instance:

REQUEST:
GET /dw/shop/v19_3/products/123/variations?select=(name,id,variation_attributes.(**)) HTTP/1.1
Host: example.com
Accept: application/json

RESPONSE:
HTTP/1.1 200 OK
Content-Length: 29
Content-Type: application/json; charset=UTF-8

{
  "_v":"19.3",
  "name":"foo",
  "id":"123",
  "variation_attributes":[{
    "id":"color",
    "name":"Color",
    "values":[{
       "value":"red",
       "name":"Red",
       "description":""
    },
    {
       "value":"blue",
       "name":"Blue",
       "description":""
    }]
  },
  {
    "id":"size",
    "name":"Size",
    "values":[{
       "value":"M",
       "name":"Medium",
       "description":""
    },
    {
       "value":"L",
       "name":"Large",
       "description":""
    }]
  }]
}