docs
  1. SCAYLE Resource Center
  2. Admin API
  3. Getting Started
  4. Nested Resources

Nested Resources

Many resources allow you to request additional information as a nested resource by using the with request parameter.

This parameter is available on all Admin API requests and applies the requested additional resources to the response.

By default, an Admin API response will only contain the requested resource. If you want to include additional resources in the response, you have to explicitly define their names in the with parameter.

The 'With' Parameter

with

String

Comma separated list of resource names to include.

Basic Usage

You can include resources by specifying them as comma separated lists. For example, setting the with parameter to images,variants on a product will include all images and variants in the response.

Recursive Usage

You can include nested resources recursively by specifying nested fields after a dot. For example, setting the with parameter to images.attributes,variants.attributes on a product will include all images and variants with their attributes in the response.

Example

Products with Images, Variants, and Variant Attributes

$options = [
    'with' => 'images,variants.attributes'
];
$productCollection = $adminApi->products->all($options);

foreach($productCollection->getEntities() as $product) {
    foreach($product->images as $image) {
        echo $image->assetUrl;
    }
}