List Categories
Retrieve all product categories.
Updated
On this page
Overview
Fetch all categories for navigation menus, sidebars, and filter UIs. Categories support nesting (parent/child) for hierarchical navigation.
SDK Usage
import dash from "@/lib/dash"
// Flat list of all categories
const { categories } = await dash.categories.list()
// Nested tree structure
const { categories: tree } = await dash.categories.getTree()
// Categories at a specific depth
const { categories: topLevel } = await dash.categories.getByDepth(0)
// Children of a specific category
const { categories: children } = await dash.categories.getChildren("flower")
Parameters
| Parameter | Type | Description |
|---|---|---|
tree | boolean | Return categories as a nested tree |
parent | string | Filter by parent category slug |
depth | number | Filter by nesting depth (0 = top-level) |
customFields | object | Filter by custom field values |
Category Object
{
"id": "cat_abc123",
"name": "Flower",
"slug": "flower",
"description": "Premium cannabis flower",
"image": "https://cdn.dashfordevs.com/...",
"hero_image": "https://...",
"parent_id": null,
"navbar_name": "Flower",
"navbar_caption": "Shop our flower collection",
"show_in_home": true,
"custom_fields": {},
"seo_title": "Shop Flower",
"seo_description": "Browse our flower selection"
}
Tree Structure
When using getTree(), child categories are nested under their parents:
[
{
"id": "cat_1",
"name": "Flower",
"slug": "flower",
"children": [
{ "id": "cat_2", "name": "Indica", "slug": "indica", "children": [] },
{ "id": "cat_3", "name": "Sativa", "slug": "sativa", "children": [] }
]
},
{
"id": "cat_4",
"name": "Edibles",
"slug": "edibles",
"children": []
}
]
Navigation Example
// app/components/CategoryNav.tsx
import dash from "@/lib/dash"
export default async function CategoryNav() {
const { categories } = await dash.categories.getTree()
return (
<nav>
{categories.map(cat => (
<div key={cat.id}>
<a href={`/category/${cat.slug}`}>{cat.name}</a>
{cat.children?.length > 0 && (
<ul>
{cat.children.map(child => (
<li key={child.id}>
<a href={`/category/${child.slug}`}>{child.name}</a>
</li>
))}
</ul>
)}
</div>
))}
</nav>
)
}
REST API
# Flat list
GET /storefront/categories
X-API-Key: pk_live_your_key
# Tree structure
GET /storefront/categories?tree=true
# Children of a parent
GET /storefront/categories?parent=flower
Next Steps
- Category Products — Get products within a category
- List Products — Filter products by category
- Category SEO — SEO metadata for category pages