product - JS SDK Store Reference

This documentation provides a reference to the sdk.store.product set of methods used to send requests to Medusa's Store API routes.

list#

This method retrieves a list of products. It sends a request to the List Products API route.

Related guides:

Example#

To retrieve the list of products:

Code
1sdk.store.product.list()2.then(({ products, count, offset, limit }) => {3  console.log(products)4})

To configure the pagination, pass the limit and offset query parameters.

For example, to retrieve only 10 items and skip 10 items:

Code
1sdk.store.product.list({2  limit: 10,3  offset: 104})5.then(({ products, count, offset, limit }) => {6  console.log(products)7})

Using the fields query parameter, you can specify the fields and relations to retrieve in each product:

Code
1sdk.store.product.list({2  fields: "id,*collection"3})4.then(({ products, count, offset, limit }) => {5  console.log(products)6})

Learn more about the fields property in the API reference.

Parameters#

Filters and pagination configurations.
headersClientHeadersOptional
Headers to pass in the request.

Returns#

PromisePromise<StoreProductListResponse>
The paginated list of products.

retrieve#

This method is used to retrieve a product by its ID. It sends a request to the Get Product API route.

Related guides:

Example#

To retrieve a product by its ID:

Code
1sdk.store.product.retrieve("prod_123")2.then(({ product }) => {3  console.log(product)4})

To specify the fields and relations to retrieve:

Code
1sdk.store.product.retrieve("prod_123", {2  fields: "id,*collection"3})4.then(({ product }) => {5  console.log(product)6})

Learn more about the fields property in the API reference.

Parameters#

idstring
The product's ID.
queryStoreProductParamsOptional
Configure the fields to retrieve in the product.
headersClientHeadersOptional
Headers to pass in the request

Returns#

PromisePromise<StoreProductResponse>
The product.
Was this page helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break