**版本：202201**

# 查询商品库存详情

**GET** `/openapi/2022-01/products/:product_id/inventory`

通过商品 ID 获取指定商品的库存详情。

## 请求

**Path参数**

- `product_id` string (required)

  商品 ID。

**Query参数**

- `location_id` string

  地点 ID（可选；指定后只返回该地点的库存）。

## 响应

**200 | 500**

200

**application/json**

**数据结构 | 示例 | Result**

**数据结构**

- `product_id` string

  **示例：** `f854e9a2-986d-4e2b-9df0-8e4c139ae80e`
- `variants` object[]

  *   Array [

  - `variant_id` string

    **示例：** `5723299f-238a-4491-8b42-a187462e748a`
  - `location_items` object[]

    *   Array [

    - `location_id` integer

      **默认值：** `0`

      **示例：** `327627904831724000`
    - `stock` integer

      **默认值：** `0`

      **示例：** `1`
    *   ]
  *   ]

```json
{
  "product_id": "f854e9a2-986d-4e2b-9df0-8e4c139ae80e",
  "variants": [
    {
      "variant_id": "5723299f-238a-4491-8b42-a187462e748a",
      "location_items": [
        {
          "location_id": 327627904831724000,
          "stock": 1
        }
      ]
    }
  ]
}
```

```json
{
    "product_id": "f854e9a2-986d-4e2b-9df0-8e4c139ae80e",
    "variants": [
        {
            "variant_id": "5723299f-238a-4491-8b42-a187462e748a",
            "location_items": [
                {
                    "location_id": 327627904831724058,
                    "stock": 1
                }
            ]
        }
    ]
}
```

500

**application/json**

**数据结构 | 示例 | Result**

**数据结构**

- `errors` string[]

```json
{
  "errors": [
    "invalid UUID length: 10"
  ]
}
```

```json
{
  "errors": [
    "invalid UUID length: 10"
  ]
}
```
