Product Endpoints
Create Product
This endpoint adds a new product to the system.
Endpoint: POST /api/v1/products
Request Body:
{
"SKU": "SHD-101",
"Name": "Aviator Sunglasses",
"price": 49.99,
"thumbnails": [
"https://example.com/images/shades1_front.jpg",
"https://example.com/images/shades1_side.jpg"
],
"colors": ["Black", "Gold", "Silver"],
"description": "Stylish aviator sunglasses with UV protection and lightweight metal frame.",
"stock": 120
}
Example Request:
curl -X POST -H "Content-Type: application/json" \
-d '{
"SKU": "SHD-101",
"Name": "Aviator Sunglasses",
"price": 49.99,
"thumbnails": [
"https://example.com/images/shades1_front.jpg",
"https://example.com/images/shades1_side.jpg"
],
"colors": ["Black", "Gold", "Silver"],
"description": "Stylish aviator sunglasses with UV protection and lightweight metal frame.",
"stock": 120
}' http://localhost:4000/api/v1/products
Get All Products
This endpoint returns a list of all available products.
Endpoint: GET /api/v1/products
Response Body (Example):
[
{
"id": "2333333333333",
"SKU": "SHD-101",
"Name": "Aviator Sunglasses",
"price": 49.99,
"thumbnails": [...],
"colors": ["Black", "Gold", "Silver"],
"description": "Stylish aviator sunglasses...",
"stock": 120
}
]
Example Request:
curl http://localhost:4000/api/v1/products
Get Single Product
This endpoint returns details for a specific product by its ID.
Endpoint: GET /api/v1/products/:id
Response Body:
{
"id": "2333333333333",
"SKU": "SHD-101",
"Name": "Aviator Sunglasses",
"price": 49.99,
"thumbnails": [
"https://example.com/images/shades1_front.jpg",
"https://example.com/images/shades1_side.jpg"
],
"colors": ["Black", "Gold", "Silver"],
"description": "Stylish aviator sunglasses with UV protection and lightweight metal frame.",
"stock": 120
}
Example Request:
curl http://localhost:4000/api/v1/products/2333333333333
Update Product
This endpoint updates the information of an existing product.
Endpoint: PUT /api/v1/products/:id
Request Body:
{
"Name": "Aviator Sunglasses Gold Edition",
"price": 54.99,
"stock": 115
}
Example Request:
curl -X PUT -H "Content-Type: application/json" \
-d '{
"SKU": "SHD-101",
"Name": "Aviator Sunglasses",
"price": 49.99,
"stock": 120
}' http://localhost:4000/api/v1/products/2333333333333
Delete Product
This endpoint removes a product from the system.
Endpoint: DELETE /api/v1/products/:id
Example Request:
curl -X DELETE http://localhost:4000/api/v1/products/2333333333333