Frontend API
Retrieve product categories to display in a storefront.
Returns a list of product categories, with offset pagination using limit and page.
List categories
await swell.categories.list({
limit: 25,
page: 1
})
Returns a single category.
Get a category
await swell.categories.get('mens-shirts')Retrieve product categories to display in a storefront.
List categories
Returns a list of product categories, with offset pagination using limit and page. Use this query to optimize your store by pre-generating data for each category page ahead of time.
The parameters for this query are search, where, sort, limit, page, _locale, and _currency.
List categories
# Returns 10 categories per page, starting on page 2.
query getCategories {
categories(limit: 10, page: 2) {
results {
name
slug
}
}
}Get a category
Returns a single category by slug or ID, including its products and images. Use this query to pre-load category data for your storefront pages.
Parameters
- For querying categoryBySlug: slug (required), _locale, and _currency
- For querying categoryById: id (required), _locale, and _currency
Get a category
# Returns categories and their images by slug.
query getCategoryPreviewData {
categoryBySlug(slug: "mens-shirt", _locale: "en-US") {
name
slug
products {
id
name
slug
price
currency
}
images {
caption
file {
url
width
height
}
}
}
}