- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
Menu
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
Retrieve Nested Categories in Storefront
A product category has parent and child categories.
To retrieve the child or nested categories of a category in your storefront, pass to the Get a Category API Route the following query parameters:
include_descendants_tree=true
to retrieve each category's nested categories at all levels.- Add
category_children
tofields
, which is the field that will hold a category's nested categories. You can either pass*category_children
to retrieve all fields of a child category, or specify the fields specifically to avoid a large response size. For example,field=category_children.id,category_children.name
. parent_category_id=null
to retrieve only the categories that don't have a parent. This avoids retrieving the child categories multiple times in the response since child categories are now set in their parent's object.
For example:
The product_category
field in the response has a category_children
field. It's an array of product category objects.
Was this page helpful?