Skip to main content
Skip to main content

ProductTypesResource

This class is used to send requests to Store Product Type API Routes. All its method are available in the JS Client under the medusa.productTypes property.

Product types are string values that can be used to filter products by. Products can have more than one tag, and products can share types.

Methods

list

Retrieve a list of product types. The product types can be filtered by fields such as value or q passed in the query parameter. The product types can also be sorted or paginated.

Example

To list product types:

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.productTypes.list()
.then(({ product_types }) => {
console.log(product_types.length);
})

By default, only the first 20 records are retrieved. You can control pagination by specifying the limit and offset properties:

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.productTypes.list({
limit,
offset
})
.then(({ product_types }) => {
console.log(product_types.length);
})

Parameters

Filters and pagination configurations to apply on retrieved product types.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<StoreProductTypesListRes>Required
Resolves to the list of product types with pagination fields.
Was this section helpful?