---
title: ZEPETO.Inventory
slug: world-sdk-guide-ch/zepetoinventory
docTags: 
createdAt: 2026-09-04T06:01:24.971Z
---

| 类型                                                  | 说明                                              |
| --------------------------------------------------- | ----------------------------------------------- |
| [InventoryListResponse](./#inventorylistresponse)   | `InventoryListResponse` 类提供 API 调用结果以及商品库存信息列表。 |
| [InventoryRecord](./#inventoryrecord)               | 库存商品信息。                                         |
| [InventoryResponse](./#inventoryresponse)           | `InventoryResponse` 类提供 API 调用结果以及获取到的库存商品信息。   |
| [InventoryService](./#inventoryservice)             | `InventoryService` 用于管理与玩家的 World 内商品库存相关的操作。   |
| [CheckInventoryRequest](./#checkinventoryrequest)   | 用于检查用户库存中是否存在指定商品的类。                            |
| [CheckInventoryResponse](./#checkinventoryresponse) | 表示库存中商品存在性检查响应的类。                               |
| [InventoryError](./#inventoryerror)                 | 表示库存相关请求失败原因的错误代码。                              |

## InventoryListResponse

`class` · extends `ProductBaseResponse`

`InventoryListResponse` 类提供 API 调用结果以及商品库存信息列表。

### 属性

| 名称       | 类型                                        | 说明        |
| -------- | ----------------------------------------- | --------- |
| products | [InventoryRecord\[\]](./#inventoryrecord) | 商品库存信息列表。 |

## InventoryRecord

`class`

库存商品信息。

### 属性

| 名称        | 类型       | 说明                |
| --------- | -------- | ----------------- |
| productId | `string` | 商品 ID。            |
| quantity  | `bigint` | 商品数量。             |
| createdAt | `Date`   | 商品被添加到库存的日期和时间。   |
| updatedAt | `Date`   | 商品信息最后一次更新的日期和时间。 |

## InventoryResponse

`class` · extends `ProductBaseResponse`

`InventoryResponse` 类提供 API 调用结果以及获取到的库存商品信息。

### 属性

| 名称      | 类型                                    | 说明      |
| ------- | ------------------------------------- | ------- |
| product | [InventoryRecord](./#inventoryrecord) | 库存商品信息。 |

## InventoryService

`class`

`InventoryService` 用于管理与玩家的 World 内商品库存相关的操作。

### 方法

### GetListAsync

`static GetListAsync() → BaseRequest<InventoryListResponse>`

该异步方法用于获取玩家的商品库存信息列表。

**返回值：** `BaseRequest<InventoryListResponse>` — 一个 `BaseRequest` 对象。异步处理完成后，可通过 `responseData` 属性访问 `InventoryListResponse` 对象。

### GetAsync

`static GetAsync(productId: string) → BaseRequest<InventoryResponse>`

该异步方法根据提供的商品 ID 获取玩家的商品库存信息。

| 参数        | 类型       | 说明         |
| --------- | -------- | ---------- |
| productId | `string` | 要获取的商品 ID。 |

**返回值：** `BaseRequest<InventoryResponse>` — 一个 `BaseRequest` 对象。异步处理完成后，可通过 `responseData` 属性访问 `InventoryResponse` 对象。

### HasAsync

`static HasAsync(productId: string) → CheckInventoryRequest`

该异步方法用于检查玩家库存中是否存在指定商品。

| 参数        | 类型       | 说明         |
| --------- | -------- | ---------- |
| productId | `string` | 要检查的商品 ID。 |

**返回值：** [CheckInventoryRequest](./#checkinventoryrequest) — 一个 `CheckInventoryRequest` 对象。异步处理完成后，可通过 `responseData` 属性访问 `CheckInventoryResponse` 对象。

## CheckInventoryRequest

`class` · extends `BaseAPIRequest`

用于检查用户库存中是否存在指定商品的类。

### 属性

| 名称           | 类型                                                  | 说明                            |
| ------------ | --------------------------------------------------- | ----------------------------- |
| responseData | [CheckInventoryResponse](./#checkinventoryresponse) | CheckInventoryResponse 的响应数据。 |

## CheckInventoryResponse

`class` · extends `ProductBaseResponse`

表示库存中商品存在性检查响应的类。

### 属性

| 名称      | 类型        | 说明                    |
| ------- | --------- | --------------------- |
| isExist | `boolean` | 表示指定商品是否存在于用户库存中的布尔值。 |

## InventoryError

`enum`

表示库存相关请求失败原因的错误代码。

| 名称           | 值  | 说明                          |
| ------------ | -- | --------------------------- |
| Unknown      | -1 | 错误：未知错误。                    |
| NetworkError | 0  | 错误：与网络问题相关的错误，包括连接中断或连接不稳定。 |
