Products API
Base path: /api/products
File: ayts-api/src/routes/products.ts
GET /api/products
List products with filters.
Query params:
| Param | Type | Description |
|---|---|---|
storeId | UUID | Filter by store |
category | string | Filter by category |
status | available|out_of_stock|archived | Filter by availability |
minPrice | number | Price range filter |
maxPrice | number | Price range filter |
limit | number | Page size (default: 20) |
offset | number | Pagination offset |
Response 200:
{
"success": true,
"products": [{
"id": "uuid",
"storeId": "uuid",
"name": "Sinandomeng Rice 5kg",
"description": "...",
"price": 285.00,
"stockCount": 50,
"category": "staples",
"status": "available",
"imageUrl": "https://r2...",
"additionalImages": [],
"store": { "name": "Fresh Mart Grocery", "id": "uuid" }
}],
"total": 120
}
GET /api/products/:id
Get a single product with full details, reviews, and store info.
POST /api/products
Create a product. Requires vendor (own store) or admin role.
{
"storeId": "uuid",
"name": "Sinandomeng Rice 5kg",
"description": "Premium quality rice",
"price": 285.00,
"stockCount": 50,
"category": "staples",
"status": "available",
"imageUrl": "https://r2...",
"additionalImages": ["https://r2..."]
}
PATCH /api/products/:id
Update a product. Requires owner or admin.
DELETE /api/products/:id
Archive a product (soft delete). Requires owner or admin.
PATCH /api/products/:id/stock
Update stock count only.
{ "stockCount": 45 }