Get All Product Groups
This endpoint retrieves a list of all product groups with their associated products, providing details such as the group name, status, creation and update timestamps, and paginated product information.
Endpoint
- URL:
/productGroup/all - Method:
GET
Authentication
- Header:
accessToken - Type: Bearer Token
- Value:
<ACCESS-TOKEN>
Query Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
page | number | Page number for product group pagination | 1 |
limit | number | Number of product groups per page (max 50) | 10 |
search | string | Search product groups by name | - |
productPage | number | Page number for products within each group | 1 |
productLimit | number | Number of products per group (max 50) | 5 |
productSearch | string | Search products by name or SKU within groups | - |
Request Headers
| Header | Type | Description |
|---|---|---|
accessToken | string | Access token for authentication. (required) |
Example Request
Here is an example using curl to get all product groups with pagination:
curl --location '<BASE-URL>/productGroup/all?page=1&limit=5&productPage=1&productLimit=3&search=Electronics&productSearch=iPhone' \
--header 'accessToken: <ACCESS-TOKEN>'
Response
- Status Code: 200 OK
Success Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates whether the request was successful. |
data | array | List of product groups with their products and details. |
pagination | object | Pagination details for product groups including page, total, etc. |
Product Group Object
| Field | Type | Description |
|---|---|---|
id | string | The unique identifier of the product group. |
name | string | The name of the product group. |
status | boolean | The status of the product group (e.g., active or inactive). |
restrictAccess | boolean | Whether access to this group is restricted. |
createdAt | string | The timestamp indicating when the product group was created. |
updatedAt | string | The timestamp indicating the last update time of the product group. |
products | array | Array of products belonging to this group. |
productCount | number | Total number of products in this group. |
productPagination | object | Pagination details for products within this group. |
Example Success Response
{
"success": true,
"data": [
{
"id": "66d220c8f57178681728212e",
"name": "Electronics",
"status": true,
"restrictAccess": false,
"createdAt": "2024-08-30T19:43:04.216Z",
"updatedAt": "2024-08-31T18:18:28.191Z",
"productCount": 25,
"products": [
{
"id": "64f123abc456789012345679",
"name": "iPhone 15",
"sku": "IPH15-001",
"price": 999,
"status": "active",
"variants": [
{
"id": "64f123abc456789012345680",
"sku": "IPH15-128GB-BLACK",
"name": "iPhone 15 128GB Black",
"price": 999,
"cost": 750,
"options": [
{
"optionName": "Storage",
"optionValueLabel": "128GB",
"optionValue": "128gb"
}
],
"inventory": {
"stock": 50,
"minStock": 10
},
"isActive": true
}
],
"categories": ["electronics", "phones"],
"mediaGallery": [...],
"seo": {...}
}
],
"productPagination": {
"page": 1,
"total": 25,
"count": 3,
"limit": 3
}
},
{
"id": "66f552c4e306999fab205805",
"name": "Clothing",
"status": true,
"restrictAccess": false,
"createdAt": "2024-09-26T12:25:40.071Z",
"updatedAt": "2024-09-26T12:25:40.071Z",
"productCount": 12,
"products": [...],
"productPagination": {
"page": 1,
"total": 12,
"count": 3,
"limit": 3
}
}
],
"pagination": {
"page": 1,
"total": 2,
"count": 2,
"limit": 10
}
}
Error Responses
| Status Code | Description |
|---|---|
| 401 | Unauthorized: Access token is invalid or missing. |
| 500 | Internal Server Error: An error occurred on the server. |
Notes
- Dual Pagination: This endpoint supports pagination at two levels:
- Product Group Level: Use
pageandlimitfor product groups - Product Level: Use
productPageandproductLimitfor products within each group
- Product Group Level: Use
- Dual Search: Search functionality is available at both levels:
- Group Search: Use
searchto filter product groups by name - Product Search: Use
productSearchto filter products by name or SKU within groups
- Group Search: Use
- Performance Optimization: The API uses aggregation queries and efficient counting to minimize database load
- Complete Data: Each product group includes full product information with variants, categories, and other metadata
- ID Conversion: All
_idfields are automatically converted toidin the response - Count Information: Each group includes
productCountshowing total products andproductPaginationfor navigation - Ensure you include a valid
accessTokenin the request to authenticate - Maximum limits are 50 for both product groups and products per group to prevent performance issues