Skip to main content
GET
/
store
/
products
/
{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.product.retrieve("prod_123")
.then(({ product }) => {
  console.log(product)
})
{
  "product": {
    "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'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.

region_id
string

The ID of the region the product is being viewed from. This is required if you're retrieving product variant prices with taxes.

country_code
string

The country code the product is being viewed from. This is required if you're retrieving product variant prices with taxes.

province
string

The lower-case ISO 3166-2 province code the product is being viewed from. This is useful to narrow down the tax context when calculating product variant prices with taxes.

Example:

"us-ca"

cart_id
string

The ID of the customer's cart. If set, the cart's region and shipping address's country code and province are used instead of the region_id, country_code, and province properties.

locale
string

The locale in BCP 47 format to retrieve localized content.

Example:

"en-US"

Response

OK

The product's details.

product
object
required

The product's details.