🛍️ Product API Testing Interface

Test all CRUD operations with live API calls

📋 Sample API Responses

Below are example responses you'll receive from each API endpoint:

✅ GET /products - Success Response

Status: 200 OK
[
  {
    "id": 1,
    "title": "Laptop",
    "price": 80000,
    "stock": 10
  },
  {
    "id": 2,
    "title": "Mouse",
    "price": 500,
    "stock": 100
  }
]

✅ GET /products/1 - Success Response

Status: 200 OK
{
  "id": 1,
  "title": "Laptop",
  "price": 80000,
  "stock": 10
}

❌ GET /products/999 - Error Response

Status: 404 Not Found
{
  "message": "Product not found"
}

✅ POST /products - Success Response

Status: 201 Created
Request Body:
{
  "title": "Keyboard",
  "price": 1500,
  "stock": 50
}
Response:
{
  "id": 3,
  "title": "Keyboard",
  "price": 1500,
  "stock": 50
}

❌ POST /products - Validation Error

Status: 400 Bad Request
Request Body (Missing fields):
{
  "title": "Keyboard"
}
Response:
{
  "message": "All fields are required"
}

✅ PUT /products/1 - Success Response

Status: 200 OK
Request Body (Partial update):
{
  "price": 75000
}
Response:
{
  "id": 1,
  "title": "Laptop",
  "price": 75000,
  "stock": 10
}

❌ PUT /products/999 - Error Response

Status: 404 Not Found
{
  "message": "Product not found"
}

✅ DELETE /products/2 - Success Response

Status: 200 OK
{
  "message": "Product deleted successfully"
}

❌ Network/Connection Error

⚠️ Common Issue: Server not running on http://localhost:3000
{
  "error": "Failed to fetch"
}
GET /products

Retrieve all products from the inventory.

curl http://localhost:3000/products

Response:


            
GET /products/:id

Retrieve a specific product by its ID.

curl http://localhost:3000/products/1

Response:


            
POST /products

Create a new product in the inventory.

curl -X POST http://localhost:3000/products \
-H "Content-Type: application/json" \
-d '{"title":"Keyboard","price":1500,"stock":50}'

Response:


            
PUT /products/:id

Update an existing product. Leave fields empty to keep current values.

curl -X PUT http://localhost:3000/products/1 \
-H "Content-Type: application/json" \
-d '{"price":75000}'

Response:


            
DELETE /products/:id

Delete a product from the inventory.

curl -X DELETE http://localhost:3000/products/2

Response: