Skip to main content
Skip to main content

listInventoryItems - Inventory Module Reference

This documentation provides a reference to the listInventoryItems method. This belongs to the Inventory Module.

This method is used to retrieve a paginated list of inventory items along with the total count of available inventory items satisfying the provided filters.

Example

To retrieve a list of inventory items using their IDs:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveInventoryItems (ids: string[]) {
const inventoryModule = await initializeInventoryModule({})

const [inventoryItems, count] = await inventoryModule.listInventoryItems({
id: ids
})

// do something with the inventory items or return them
}

To specify relations that should be retrieved within the inventory items:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveInventoryItems (ids: string[]) {
const inventoryModule = await initializeInventoryModule({})

const [inventoryItems, count] = await inventoryModule.listInventoryItems({
id: ids
}, {
relations: ["inventory_level"]
})

// do something with the inventory items or return them
}

By default, only the first 10 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveInventoryItems (ids: string[], skip: number, take: number) {
const inventoryModule = await initializeInventoryModule({})

const [inventoryItems, count] = await inventoryModule.listInventoryItems({
id: ids
}, {
relations: ["inventory_level"],
skip,
take
})

// do something with the inventory items or return them
}

Parameters

The filters to apply on the retrieved inventory items.
The configurations determining how the inventory items are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a inventory item.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<[InventoryItemDTO[], number]>Required
The list of inventory items along with the total count.
Was this section helpful?