Products API
E-commerce products with categories, stock management, and nested reviews functionality.
List Products
Get a paginated list of products with optional category filtering.
GET https://responserift.dev/api/products?category=Tech%20Gadgets&limit=5&offset=0
Query Parameters
category
- Filter by category (case-insensitive)limit
- Number of results (default: 100)offset
- Number of results to skip (default: 0)
Response
{
"total": 50,
"limit": 5,
"offset": 0,
"results": [
{
"id": 1,
"title": "Wireless Bluetooth Headphones",
"description": "High-quality wireless headphones with noise cancellation...",
"price": 99.99,
"image": "https://picsum.photos/seed/headphones/400/300",
"category": "Tech Gadgets",
"stock": 25
}
]
}
Get Product
Retrieve a specific product by ID.
GET https://responserift.dev/api/products/1
Create Product
Create a new product. All fields are required.
POST https://responserift.dev/api/products
Content-Type: application/json
{
"title": "Sample Product",
"description": "A sample product description",
"price": 29.99,
"image": "https://picsum.photos/seed/sample/400/300",
"category": "Misc",
"stock": 10
}
Required fields: title, description, price, image, category, stock
Validation: price must be non-negative, stock must be non-negative
Update Product
Update an existing product. Only provided fields will be updated.
PUT https://responserift.dev/api/products/1
Content-Type: application/json
{ "price": 89.99, "stock": 15 }
Delete Product
Remove a product from the system.
DELETE https://responserift.dev/api/products/1
Product Reviews
Nested endpoint to manage reviews for a specific product.
List Reviews
GET https://responserift.dev/api/products/1/reviews
Create Review
POST https://responserift.dev/api/products/1/reviews
Content-Type: application/json
{
"userId": 2,
"rating": 5,
"comment": "Excellent product! Great sound quality and comfortable fit."
}
Note: Reviews are automatically associated with the product ID from the URL path.
Rating: Must be between 1 and 5 stars.
Warning: All mutations are in-memory only and reset on server restart.