Skip to main content

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

ParameterTypeDescriptionDefault
pagenumberPage number for product group pagination1
limitnumberNumber of product groups per page (max 50)10
searchstringSearch product groups by name-
productPagenumberPage number for products within each group1
productLimitnumberNumber of products per group (max 50)5
productSearchstringSearch products by name or SKU within groups-

Request Headers

HeaderTypeDescription
accessTokenstringAccess 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

FieldTypeDescription
successbooleanIndicates whether the request was successful.
dataarrayList of product groups with their products and details.
paginationobjectPagination details for product groups including page, total, etc.

Product Group Object

FieldTypeDescription
idstringThe unique identifier of the product group.
namestringThe name of the product group.
statusbooleanThe status of the product group (e.g., active or inactive).
restrictAccessbooleanWhether access to this group is restricted.
createdAtstringThe timestamp indicating when the product group was created.
updatedAtstringThe timestamp indicating the last update time of the product group.
productsarrayArray of products belonging to this group.
productCountnumberTotal number of products in this group.
productPaginationobjectPagination 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 CodeDescription
401Unauthorized: Access token is invalid or missing.
500Internal Server Error: An error occurred on the server.

Notes

  • Dual Pagination: This endpoint supports pagination at two levels:
    • Product Group Level: Use page and limit for product groups
    • Product Level: Use productPage and productLimit for products within each group
  • Dual Search: Search functionality is available at both levels:
    • Group Search: Use search to filter product groups by name
    • Product Search: Use productSearch to filter products by name or SKU within groups
  • 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 _id fields are automatically converted to id in the response
  • Count Information: Each group includes productCount showing total products and productPagination for navigation
  • Ensure you include a valid accessToken in the request to authenticate
  • Maximum limits are 50 for both product groups and products per group to prevent performance issues