Skip to main content

GET /api/products

Retrieves the product catalog with all active products. This endpoint provides backward compatibility with the legacy SheetDB format.

Query Parameters

sheet
string
Optional filter by category/sheet name (e.g., “Kits”, “Productos”). If omitted, returns all products.

Response

Returns an array of product objects in legacy SheetDB format.
SKU
string
Product SKU identifier
NOMBRE
string
Product name
DESCRIPCION_LARGA
string
Full product description
DESCRIPCION_CORTA
string
Short description (first 100 characters)
PRECIO
string
Product price as string
STOCK
string
Stock status: “DISPONIBLE” or “AGOTADO”
IMAGEN_URL
string
Primary product image URL
CATEGORIA
string
Product category (e.g., “General”, “Kits”)
BENEFICIOS
string
Product benefits description
PESO
string
Weight in kilograms (default: “0.2”)
ALTO
string
Height in centimeters (default: “10”)
ANCHO
string
Width in centimeters (default: “10”)
LARGO
string
Length in centimeters (default: “10”)
VARIANT_NAME
string
Variant name if applicable

Example Request

curl http://localhost:3001/api/products

Example Request with Filter

curl http://localhost:3001/api/products?sheet=Kits

Example Response

[
  {
    "SKU": "SERUM-VITAMIN-C",
    "NOMBRE": "Serum Vitamina C",
    "DESCRIPCION_LARGA": "Serum facial con vitamina C para iluminar y revitalizar la piel. Fórmula natural con ingredientes orgánicos.",
    "DESCRIPCION_CORTA": "Serum facial con vitamina C para iluminar y revitalizar la piel. Fórmula natural con ingredient...",
    "PRECIO": "89000",
    "STOCK": "DISPONIBLE",
    "IMAGEN_URL": "https://example.com/serum-vitamin-c.jpg",
    "CATEGORIA": "Serums",
    "BENEFICIOS": "Ilumina, revitaliza, reduce manchas",
    "PESO": "0.15",
    "ALTO": "12",
    "ANCHO": "4",
    "LARGO": "4",
    "VARIANT_NAME": ""
  },
  {
    "SKU": "KIT-FACIAL-COMPLETO",
    "NOMBRE": "Kit Facial Completo",
    "DESCRIPCION_LARGA": "Kit completo para el cuidado facial. Incluye limpiador, tónico, serum y crema hidratante.",
    "DESCRIPCION_CORTA": "Kit completo para el cuidado facial. Incluye limpiador, tónico, serum y crema hidratante.",
    "PRECIO": "250000",
    "STOCK": "DISPONIBLE",
    "IMAGEN_URL": "https://example.com/kit-facial.jpg",
    "CATEGORIA": "Kits",
    "BENEFICIOS": "Rutina completa, ahorro, productos complementarios",
    "PESO": "0.8",
    "ALTO": "20",
    "ANCHO": "15",
    "LARGO": "10",
    "VARIANT_NAME": ""
  }
]

Data Source

Products are fetched from the PostgreSQL database using Prisma ORM. Only products with isActive: true are returned.

Caching

The endpoint includes cache control headers to prevent caching:
Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate

Legacy Format

This endpoint maintains backward compatibility with the legacy SheetDB integration. The response format uses uppercase field names and string values for prices to match the original implementation.

Filtering Logic

When a sheet parameter is provided:
  • Filters products where CATEGORIA contains the sheet name
  • Or where NOMBRE contains the sheet name
  • Case-sensitive partial match

Error Responses

500 Internal Server Error

{
  "error": "Failed to fetch products from DB",
  "details": "Database connection error"
}

CORS Headers

The endpoint includes CORS headers:
  • Access-Control-Allow-Credentials: true
  • Access-Control-Allow-Origin: *

Build docs developers (and LLMs) love