Including associations
How to include a resource and its associations in the same request
Last updated
How to include a resource and its associations in the same request
Last updated
When you fetch a resource or a collection, you can include its associations in the same request, using the include
query parameter. This reduces the number of roundtrips, optimizing the performances.
The value of the include
parameter must be a comma-separated list of relationship paths () — make sure to avoid whitespaces before or after each comma. A relationship path is a dot-separated list of relationship names (). For each included resource you'll find in the relationships
object of the response an additional data
array containing their type and ID.
The following request fetches the SKU identified by the ID "xYZkjABcde" and the related prices and stock items:
The following request features the relationship path stock_items.reserved_stock
as the value of the include parameter, where stock_items
is a relationship listed under the SKU resource object, and reserved_stock
is a relationship listed under the stock item resource object:
You can request to include associations also when or resources.