To minimize network traffic and server CPU usage, the Open Commerce API sometimes uses a technique called expansion. This technique intentionally omits parts of a selected resource, reducing the size of the overall response. However, if you want to include the parts that are omitted by default, you can explicitly request the omitted parts by using the expand query parameter. This parameter specifies a comma-separated list of entities that you want expanded, identifying each of them by name.
The products and product_search resources support the expansion technique. A resource type that enables expansions is structured into a base resource and one or more subresources. For the *products* resource, the base resource is */products/{id}*, and two of its subresources are */products/{id}/prices* and */products/{id}/variations*.
By default, the base resource returns only a basic subset of properties. A subresource returns not only the base properties but also subresource specific properties (for example, price properties). The name of the subresource is used as the expand query parameter value.
The examples below show how expansion works.
Base Resource
Request to base resource without expand parameter specified. Response document contains only some basic properties.
Single request with expand parameter. The response document contains the basic properties plus the specific properties of each subresource named in expand parameter values.
The Open Commerce API (OCAPI) is now deprecated. The provisions described in our versioning and deprecation policy fully apply. For all new projects and major refactoring work, use B2C Commerce API (SCAPI) as the default REST API. For additional details, refer to Why Use SCAPI Instead of OCAPI.
DID THIS ARTICLE SOLVE YOUR ISSUE? Let us know so we can improve!