购物车 API
商品引用真实商品 ID 的购物车。内存中的固定数据:写入会保留到应用重启为止。
你的账号已解锁这些端点。在每个端点的页面上用 Try it 发送请求。
- GET
https://api.testingapis.com/api/CartsList carts with filtering, sorting, search and paginationList carts with filtering, sorting, search and pagination. - POST
https://api.testingapis.com/api/CartsCreate a cartCreate a cart. - GET
https://api.testingapis.com/api/Carts/{id}Get a cart by IDGet a cart by ID. - PUT
https://api.testingapis.com/api/Carts/{id}Update a cartUpdate a cart. - DELETE
https://api.testingapis.com/api/Carts/{id}Delete a cartDelete a cart.
请求示例
List carts with filtering, sorting, search and pagination. 完整参考和 Send 按钮(英文).
cURL
curl -X GET "https://api.testingapis.com/api/Carts?limit=2"响应 · 200 OK
[
{
"id": 1,
"userId": 101,
"items": [
{"productId": 3, "quantity": 2, "price": 89.99},
{"productId": 7, "quantity": 1, "price": 49.99}
],
"total": 229.97,
"updatedAt": "2025-07-16T12:00:00Z"
},
{
… (3 more lines)筛选、排序与分页
列表端点接受 limit、page、offset、sort、order 和 q,任何字段名都可用作精确筛选。总数通过 X-Total-Count 响应头返回。写入的数据在服务器重启前都保存在内存中,所以测试可以随意创建、修改和删除记录。 查询参数参考.