Skip to main content
GET
/
store
/
product-categories
/
{id}
JS SDK
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.retrieve("pcat_123")
.then(({ product_category }) => {
  console.log(product_category)
})
{
  "product_category": {
    "id": "<string>",
    "name": "<string>",
    "description": "<string>",
    "handle": "<string>",
    "rank": 123,
    "parent_category_id": "<string>",
    "parent_category": {},
    "category_children": [
      {}
    ],
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z",
    "deleted_at": "2023-11-07T05:31:56Z",
    "metadata": {},
    "products": [
      {
        "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>",
        "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"
              }
            ],
            "length": 123,
            "title": "<string>",
            "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",
            "sku": "<string>",
            "barcode": "<string>",
            "ean": "<string>",
            "upc": "<string>",
            "allow_backorder": true,
            "manage_inventory": true,
            "thumbnail": "<string>",
            "images": [
              {
                "id": "<string>",
                "url": "<string>",
                "rank": 123,
                "created_at": "2023-11-07T05:31:56Z",
                "updated_at": "2023-11-07T05:31:56Z",
                "deleted_at": "2023-11-07T05:31:56Z",
                "metadata": {}
              }
            ],
            "product": {},
            "metadata": {},
            "product_id": "<string>",
            "inventory_quantity": 123,
            "variant_rank": 123,
            "calculated_price": {
              "id": "<string>",
              "calculated_amount": 123,
              "original_amount": 123,
              "currency_code": "usd",
              "original_amount_with_tax": 123,
              "original_amount_without_tax": 123,
              "is_calculated_price_price_list": true,
              "is_calculated_price_tax_inclusive": true,
              "calculated_amount_with_tax": 123,
              "calculated_amount_without_tax": 123,
              "is_original_price_price_list": true,
              "is_original_price_tax_inclusive": true,
              "calculated_price": {},
              "original_price": {}
            }
          }
        ],
        "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>",
        "type_id": "<string>",
        "images": [
          {
            "id": "<string>",
            "url": "<string>",
            "rank": 123,
            "created_at": "2023-11-07T05:31:56Z",
            "updated_at": "2023-11-07T05:31:56Z",
            "deleted_at": "2023-11-07T05:31:56Z",
            "metadata": {}
          }
        ],
        "discountable": true,
        "external_id": "<string>",
        "deleted_at": "2023-11-07T05:31:56Z",
        "categories": [
          {}
        ],
        "type": {
          "id": "<string>",
          "created_at": "2023-11-07T05:31:56Z",
          "updated_at": "2023-11-07T05:31:56Z",
          "value": "<string>",
          "metadata": {},
          "deleted_at": "2023-11-07T05:31:56Z"
        },
        "metadata": {},
        "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",
          "metadata": {},
          "products": [
            {}
          ]
        },
        "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": {}
          }
        ]
      }
    ]
  }
}

Headers

x-publishable-api-key
string
required

Publishable API Key created in the Medusa Admin.

x-medusa-locale
string

The locale in BCP 47 format to retrieve localized content.

Example:

"en-US"

Path Parameters

id
string
required

The product category's ID.

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.

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 children 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.

locale
string

The locale in BCP 47 format to retrieve localized content.

Example:

"en-US"

Response

OK

The product category's details.

product_category
object
required

The category's details.