Skip to main content
Skip to main content

listInventoryLevels - Inventory Module Reference

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

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

Example

To retrieve a list of inventory levels using their IDs:

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

async function retrieveInventoryLevels (inventoryItemIds: string[]) {
const inventoryModule = await initializeInventoryModule({})

const [inventoryLevels, count] = await inventoryModule.listInventoryLevels({
inventory_item_id: inventoryItemIds
})

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

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

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

async function retrieveInventoryLevels (inventoryItemIds: string[]) {
const inventoryModule = await initializeInventoryModule({})

const [inventoryLevels, count] = await inventoryModule.listInventoryLevels({
inventory_item_id: inventoryItemIds
}, {
relations: ["inventory_item"]
})

// do something with the inventory levels 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 retrieveInventoryLevels (inventoryItemIds: string[], skip: number, take: number) {
const inventoryModule = await initializeInventoryModule({})

const [inventoryLevels, count] = await inventoryModule.listInventoryLevels({
inventory_item_id: inventoryItemIds
}, {
relations: ["inventory_item"],
skip,
take
})

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

Parameters

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

Returns

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