跳到主要内容

商店 API 函数

借助这些 API 函数,您可以管理宠物店的库存和订单。

获取宠物库存

按状态返回宠物库存。

接口:https://petstore3.swagger.io/api/v3/store/inventory

操作:GET

示例

GET "https://petstore3.swagger.io/api/v3/store/inventory" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

响应

状态码描述
200操作成功
默认意外错误
响应示例

200: Successful operation

{
"sold": 0,
"available": 0,
"pending": 0
}

参数

下单

为宠物下单。

接口:https://petstore3.swagger.io/api/v3/store/order

操作:POST

示例

POST "https://petstore3.swagger.io/api/v3/store/order" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "api_key: <YOUR_API_KEY>" \
-d '{
"id": 0,
"petId": 0,
"quantity": 0,
"shipDate": "2025-08-11T15:13:06.939Z",
"status": "placed",
"complete": false
}'

响应

状态码描述
200操作成功
400订单无效
default意外错误
响应示例

200: Successful operation

{
"id": 0,
"petId": 0,
"quantity": 0,
"shipDate": "2025-08-11T15:13:06.939Z",
"status": "placed",
"complete": false
}

参数

请求正文
名称类型描述
body订单对象(必填) 宠物的 Order 对象。

查询订单

根据 ID 查询订单。

接口地址:https://petstore3.swagger.io/api/v3/store/order/{orderId}

操作:GET

示例

GET "https://petstore3.swagger.io/api/v3/store/order/1" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

响应

状态码描述
200操作成功
400提供的 ID 无效
404未找到订单
默认意外错误
响应示例

200: Successful operation

{
"id": 1,
"petId": 0,
"quantity": 0,
"shipDate": "2025-08-11T15:13:06.939Z",
"status": "placed",
"complete": false
}

参数

路径参数
名称类型描述
orderId整数要获取的采购订单 ID

删除订单

根据 ID 删除订单。

端点:https://petstore3.swagger.io/api/v3/store/order/{orderId}

操作:DELETE

示例

DELETE "https://petstore3.swagger.io/api/v3/store/order/1" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

响应

代码描述
200订单已删除
400提供的 ID 无效
404未找到订单
默认意外错误

(删除成功将返回 200 状态码,且无响应正文。)

参数

路径参数
名称类型描述
orderId整数要删除的订单 ID