Select Response Properties
Property selectors allow you to set which properties are returned in API responses. You can use them to remove unneeded properties from large responses, reducing their size.
To use property selectors include the select
parameter in a request. For example, to select only the name
property of getProduct, use the selector select=(name)
:
Selector values must be enclosed in parentheses. The following selectors are supported:
Capability | Value of select parameter |
---|---|
Include a single property. | (property) |
Exclude a single property. | (-property) |
Include properties of all levels, including complex properties. | (**) |
Include properties of top level, except complex properties. | (*) |
Include the child document properties. | (property.(**)) |
Return the first document. Index starts with 0. | (property[0].(**)) |
Return the first 5 documents. | (property[0:4].(**)) |
Return the second, fourth, and sixth documents. | (property[1,3,5].(**)) |
Return matching documents matching a condition. | (property[?(@.key==val)]) |
Return matching documents matching multiple conditions. | (property[?(@.key1==val1) || ?(@.key2=val2)]) |
Use a comma-separated value to select multiple properties. For example, to select name
and recommendations
including its children, use the selector select=(name,recommendations.(**)
:
To select child properties, include all result levels. For example, to select the productId
of variants
, use the selector select=(variants.(productId))
:
Selectors can also be used to exclude properties. To exclude a property, first include a property. For example, to exclude backorderable
from inventory
use select=(inventory.(*,-backorderable))
:
Selectors can be used to filter documents based on one or more conditions. For example, to filter for small
and large
images use select=(imageGroups[?(@.viewType==small || @.viewType==large)])
:
Property selectors are only supported for a subset of Shopper endpoints. You can check endpoint whether an endpoint supports select
by reviewing its query parameters in the API Reference.