GET
/
store
/
product-categories
import Medusa from "@medusajs/js-sdk"

let MEDUSA_BACKEND_URL = "http://localhost:9000"

if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
  MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
}

export const sdk = new Medusa({
  baseUrl: MEDUSA_BACKEND_URL,
  debug: process.env.NODE_ENV === "development",
  publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
})

sdk.store.category.list()
.then(({ product_categories, count, offset, limit }) => {
  console.log(product_categories)
})
{
"limit": 123,
"offset": 123,
"count": 123,
"product_categories": [
{
"id": "<string>",
"name": "<string>",
"description": "<string>",
"handle": "<string>",
"rank": 123,
"parent_category_id": "<string>",
"parent_category": {},
"category_children": [
{}
],
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"products": [
{
"categories": [
{}
],
"type": {
"id": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"value": "<string>"
},
"length": 123,
"title": "<string>",
"status": "draft",
"options": [
{
"id": "<string>",
"title": "<string>",
"product": {},
"product_id": "<string>",
"values": [
{
"id": "<string>",
"value": "<string>",
"option": {},
"option_id": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"description": "<string>",
"id": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"variants": [
{
"options": [
{
"id": "<string>",
"value": "<string>",
"option": {},
"option_id": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"product": {},
"length": 123,
"title": "<string>",
"metadata": {},
"id": "<string>",
"width": 123,
"weight": 123,
"height": 123,
"origin_country": "<string>",
"hs_code": "<string>",
"mid_code": "<string>",
"material": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"product_id": "<string>",
"sku": "<string>",
"barcode": "<string>",
"ean": "<string>",
"upc": "<string>",
"allow_backorder": true,
"manage_inventory": true,
"inventory_quantity": 123,
"variant_rank": 123,
"calculated_price": {
"id": "<string>",
"is_calculated_price_price_list": true,
"is_calculated_price_tax_inclusive": true,
"calculated_amount": 123,
"calculated_amount_with_tax": 123,
"calculated_amount_without_tax": 123,
"is_original_price_price_list": true,
"is_original_price_tax_inclusive": true,
"original_amount": 123,
"currency_code": "usd",
"calculated_price": {},
"original_price": {},
"original_amount_with_tax": 123,
"original_amount_without_tax": 123
}
}
],
"handle": "<string>",
"subtitle": "<string>",
"is_giftcard": true,
"thumbnail": "<string>",
"width": 123,
"weight": 123,
"height": 123,
"origin_country": "<string>",
"hs_code": "<string>",
"mid_code": "<string>",
"material": "<string>",
"collection": {
"id": "<string>",
"title": "<string>",
"handle": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"products": [
{}
],
"metadata": {}
},
"collection_id": "<string>",
"type_id": "<string>",
"tags": [
{
"id": "<string>",
"value": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"metadata": {}
}
],
"images": [
{
"id": "<string>",
"url": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"metadata": {},
"rank": 123
}
],
"discountable": true,
"external_id": "<string>",
"deleted_at": "2023-11-07T05:31:56Z"
}
]
}
],
"estimate_count": 123
}

Headers

x-publishable-api-key
string
required

Publishable API Key created in the Medusa Admin.

Query Parameters

fields
string

Comma-separated fields that should be included in the returned data. if a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.

offset
number

The number of items to skip when retrieving a list.

limit
number

Limit the number of items returned in the list.

order
string

The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with -.

q
string

Search term to filter the product category's properties.

id

Filter by a product category's ID.

description

Filter by a description. This only matches categories with the exact description. To search by a term or keyword, use the q query parameter instead.

handle

Filter by a category's handle.

parent_category_id

The ID of a category to retrieve its child categories.

include_ancestors_tree
boolean

Whether to retrieve the category's parent. If you enable this, add to the fields query parameter parent_category to set the parent of a category in this field. You can either pass *parent_category to retreieve the fields of all parent categories, or select specific fields to make the response size smaller. For example, fields=parent_category.id,parent_category.name.

include_descendants_tree
boolean

Whether to retrieve a list of child categories. If you enable this, add to the fields query parameter category_children to set the child of a category in this field. You can either pass *category_children to retreieve the fields of all child categories, or select specific fields to make the response size smaller. For example, fields=category_children.id,category_children.name.

created_at
object

Filter by the category's creation date.

updated_at
object

Filter by the category's update date.

$and
$and · object[]

Join query parameters with an AND condition. Each object's content is the same type as the expected query parameters.

$or
$or · object[]

The product category's $or.

name

Filter by a product category name.

with_deleted
boolean

Whether to include deleted records in the result.

Response

200
application/json

OK

The paginated list of product categories.