Skip to main content
GET
/
products
List Products
curl --request GET \
  --url https://api.example.com/products
{
  "products": [
    {
      "_id": "<string>",
      "brand": "<string>",
      "name": "<string>",
      "stock": 123,
      "price": 123,
      "normalizedName": "<string>"
    }
  ]
}
Retrieves a list of all products in the inventory.

Authentication

This endpoint does not require authentication.

Response

products
array
Array of product objects
_id
string
Unique identifier for the product
brand
string
The product brand
name
string
The product name
stock
number
The quantity in stock
price
number
The product price
normalizedName
string
Normalized version of the product name for search purposes

Status Codes

  • 200: Successfully retrieved products
  • 404: No products found in the database
  • 500: Server error

Example Request

curl http://localhost:3000/products

Example Response

{
  "products": [
    {
      "_id": "507f1f77bcf86cd799439011",
      "brand": "TechCorp",
      "name": "Wireless Mouse",
      "stock": 150,
      "price": 29.99,
      "normalizedName": "wireless mouse"
    },
    {
      "_id": "507f1f77bcf86cd799439012",
      "brand": "KeyMaster",
      "name": "Mechanical Keyboard",
      "stock": 75,
      "price": 89.99,
      "normalizedName": "mechanical keyboard"
    }
  ]
}

Error Response (404)

{
  "message": "❌ No hay productos que mostrar..."
}

Error Response (500)

{
  "message": "❌ Error en el servidor...",
  "error": "Database connection failed"
}