商品 API
带分类、价格、评分和库存的电商商品。内存中的固定数据:写入会保留到应用重启为止。
免费:这些端点无需账号。
- GET
https://api.testingapis.com/api/ProductsList products with filtering, sorting, search and pagination. - POST
https://api.testingapis.com/api/ProductsCreate a product. - GET
https://api.testingapis.com/api/Products/{id}Get a product by ID. - PUT
https://api.testingapis.com/api/Products/{id}Update a product. - DELETE
https://api.testingapis.com/api/Products/{id}Delete a product. - GET
https://api.testingapis.com/api/Products/categoriesList product categories without duplicates. - GET
https://api.testingapis.com/api/Products/category/{name}List the products in a category.
请求示例
List products with filtering, sorting, search and pagination. 完整参考和 Send 按钮(英文).
cURL
curl -X GET "https://api.testingapis.com/api/Products?limit=2"响应 · 200 OK
[
{
"id": 1,
"title": "Wireless Noise-Cancelling Headphones",
"price": 249.99,
"description": "Over-ear headphones with 30hr battery life and active noise cancellation.",
"category": "electronics",
"image": "https://picsum.photos/seed/prod1/400/400",
"rating": {"rate": 4.3, "count": 127},
"inStock": true,
"createdAt": "2025-06-12T10:30:00Z"
},
… (3 more lines)筛选、排序与分页
列表端点接受 limit、page、offset、sort、order 和 q,任何字段名都可用作精确筛选。总数通过 X-Total-Count 响应头返回。写入的数据在服务器重启前都保存在内存中,所以测试可以随意创建、修改和删除记录。 查询参数参考.