Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/floriansalvi/HEIG-VD_Ocha-api/llms.txt

Use this file to discover all available pages before exploring further.

The get product endpoint retrieves a single product by its unique MongoDB identifier. This endpoint is public and requires no authentication. If the supplied id is not a valid MongoDB ObjectId format, the API returns a 400 error immediately without querying the database.

Endpoint

GET /api/v1/products/:id
This endpoint is public. No Authorization header is required.

Path parameters

id
string
required
The MongoDB ObjectId of the product to retrieve (e.g. 64f1c2e9a1b2c3d4e5f12345). Must be a valid 24-character hexadecimal string.

Response

200 OK
message
string
A human-readable confirmation, e.g. "Product found".
product
object
The requested product.

Error codes

StatusMeaning
400Invalid ID format — the supplied id is not a valid MongoDB ObjectId.
404Product not found — no product exists with the given id.
500Internal server error — an unexpected error occurred.

Example

Request:
curl https://api.example.com/api/v1/products/64f1c2e9a1b2c3d4e5f12345
200 response:
{
  "message": "Product found",
  "product": {
    "_id": "64f1c2e9a1b2c3d4e5f12345",
    "slug": "matcha-latte",
    "name": "Matcha Latte",
    "category": "Hot drinks",
    "description": "Delicious matcha latte with a hint of sweetness.",
    "basePriceCHF": 5.00,
    "isActive": true,
    "image": "https://res.cloudinary.com/example/image/upload/products/matcha-latte.jpg",
    "size": ["S", "M", "L"],
    "extra_chf": { "S": 0, "M": 2, "L": 3 },
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-03-22T14:05:00.000Z"
  }
}
400 response (invalid ID):
{
  "message": "Invalid ID format"
}
404 response:
{
  "message": "Product not found"
}

Build docs developers (and LLMs) love