Skip to main content

Products

Get All Products

GET /adminapi/products

Query Parameters:

  • limit: Number of products to return (default: 10).
  • offset: Number of products to skip (default: 0).
  • isPublished (optional): If true, returns only published products.
  • isBestseller (optional): If true, returns only bestseller products.
  • search (optional): Search term to filter products by name, description, or category names.

Response:

{
"products": [
{
"_id": "60d5ec49f1b2c72d88f8e8b5",
"name": "Chair"
}
],
"totalProducts": 1
}

Get Product by ID

Retrieve a single product by its ID.

GET /adminapi/products/:id

Response:

{
"_id": "60d5ec49f1b2c72d88f8e8b5",
"name": "Chair"
}

Get Products by Category ID

Retrieve products by category ID.

GET /adminapi/products/category/:categoryId

Query Parameters:

  • limit (optional): Number of products to return (default: 10).
  • offset (optional): Number of products to skip (default: 0).
  • isPublished (optional): If true, returns only published products.

Response

{
"products": [
{
"_id": "60d5ec49f1b2c72d88f8e8b5",
"name": "Chair",
"isPublished": true
}
],
"totalProducts": 1
}

Search Products

Search products by name, description, or category names.

GET /adminapi/products/search

Query Parameters:

  • search: Search term.

Create Product

Create a new product.

POST /adminapi/products

Request Body:

Product Model

{
"status": "1",
"name": "Chair",
"modelPath": "path/to/model",
"materialy": {},
"main": {},
"date": "2023-10-01"
}

Response:

{
"_id": "60d5ec49f1b2c72d88f8e8b5",
"name": "Chair"
}

Update Product

Update an existing product by its ID.

PATCH /adminapi/products/:id

Request Body:

{
"name": "Updated Chair",
"newImages": ["path/to/new/image"],
"imagesToDelete": ["path/to/old/image"],
"newModelPath": "path/to/new/model",
"filePathToDelete": "path/to/old/model"
}

Upload Product Files

Uploads one or more files (images or models) for a product.

POST POST /adminapi/products/upload_image

Request:

  • Files: image (array of files).

Response

{
"message": "Files uploaded successfully!",
"files": [
{
"fieldname": "image",
"originalname": "chair.jpg",
"encoding": "7bit",
"mimetype": "image/jpeg",
"destination": "uploads/products",
"filename": "chair.jpg",
"path": "relative/path/to/chair.jpg",
"size": 12345
}
]
}

Delete Product

Deletes a product by its ID.

DELETE /adminapi/products/:id

Response

{
"message": "Deleted Product"
}