Organization
There are two ways to organize products - Categories and Collections.
Category¶
Category is way to organize products in a hierarchical tree structure. Here is an example categorical organization for a fashion store. Note that a product can only belong to single category.
stateDiagram-v2
    A: Product
    B: Product
    C: Product
    D: Product
    E: Product
    F: Product
    G: Product
    H: Product
    I: Product
    Men --> Topwear
    Men --> Bottomwear
    Topwear --> TShirts
    Topwear --> Casuals
    Topwear --> Formals
    TShirts --> A      
    TShirts --> B
    Casuals --> C      
    Casuals --> D
    Formals --> E     
    Formals --> F
    Bottomwear --> G
    Bottomwear --> H
    Bottomwear --> IstateDiagram-v2
    A: Product
    B: Product
    C: Product
    D: Product
    E: Product
    F: Product
    Women --> Western
    Women --> Fusion
    Women --> Beauty
    Western --> A
    Fusion --> B
    Beauty --> C
    Western --> D
    Fusion --> E
    Beauty --> F    Category Object¶
Below is the json representation of the category object, followed by a data table
{
  "created_at": "2023-04-05T03:58:13.793Z",
  "id": "98604997-6031-4822-956e-d2591c4dae6d",
  "name": "trending category",
  "products_count": 2,
  "sub_categories_count": 1,
  "updated_at": "2023-04-05T03:58:13.846Z",
  "visible_on_store_front": true,
  "used_for_components: false
}
Fields¶
| Field | Data Type | Description | 
|---|---|---|
| id | string | UUID of the category. | 
| name | string | Name of the category. | 
| products_count | integer | Number of products in this category. | 
| sub_categories_count | integer | Number of sub categories in this category. | 
| visible_on_store_front | boolean | Whether this category should be shown in storefront. | 
| used_for_components | boolean | Whether this category should be used as components for a custom products. | 
API¶
List Categories¶
 GET /api/platform/v1/categories
The result set is paginated and can be controlled by various query parameters
Query Params
| Field | Data Type | Description | 
|---|---|---|
| page | integer | Page number of the result set. Values start from 1. | 
| per_page | integer | How many items should be present in a given page. | 
curl command
Response Body
This api responds with array of category objects.
  {
    "status": "success",
    "data": [
      {
        "id": "acdab54b-6dd3-4200-993d-5399267a3ec9",
        "name": "Men",
        "sub_categories_count": 2,
        "products_count": 1,
        "visible_on_store_front": true,
        "used_for_components": false,
        "metadata": null,
        "extradata": null,
        "created_at": "2023-04-17T09:30:53.057Z",
        "updated_at": "2023-04-17T09:33:00.179Z",
        "account_id": "a9f7ef20-dc03-494a-9db2-cbc43ff2f564"
      },
      {
        "id": "725cad6c-0bf9-44ee-89d9-5594e6e69fc5",
        "name": "Topwear",
        "sub_categories_count": 3,
        "products_count": 1,
        "visible_on_store_front": true,
        "used_for_components": false,
        "metadata": null,
        "extradata": null,
        "created_at": "2023-04-17T09:31:13.448Z",
        "updated_at": "2023-04-17T09:33:00.184Z",
        "account_id": "a9f7ef20-dc03-494a-9db2-cbc43ff2f564"
      }
    ],
    "pagination": {
      "total_count": 6,
      "current_page": 1,
      "total_pages": 1,
      "window": 4,
      "breakdown": [
        { "kind": "inner", "url": "/api/platform/v1/categories", "page": 1 }
      ]
    }
  }
Search Categories¶
 POST /api/platform/v1/categories/search
Perform search on categories object across entire trees. Search is primarily based on name of the category.
curl command
Response Body
This api responds with array of category objects.
{
  "status": "success",
  "data": [
    {
      "used_for_components": false,
      "updated_at": "2023-04-17T09:33:00.158Z",
      "materialized_path": "Men/Topwear/Formals",
      "visible_on_store_front": true,
      "name": "Formals",
      "products_count": 1,
      "created_at": "2023-04-17T09:32:36.387Z",
      "id": "16f1301d-6852-4cfc-a2e5-9f17f466dd58",
      "sub_categories_count": 0
    },
    {
      "used_for_components": false,
      "updated_at": "2023-04-17T09:32:29.626Z",
      "materialized_path": "Men/Topwear/Casuals",
      "visible_on_store_front": false,
      "name": "Casuals",
      "products_count": 0,
      "created_at": "2023-04-17T09:32:15.038Z",
      "id": "62ea3099-e5a4-473b-98c4-5f010e43b5cc",
      "sub_categories_count": 0
    }
  ],
  "pagination": {
    "total_count": 2,
    "current_page": 1,
    "total_pages": 1,
    "window": 4,
    "breakdown": [
      {
        "kind": "inner",
        "url": "/api/platform/v1/categories/search?query=als",
        "page": 1
      }
    ]
  }
}
Create Category¶
 POST /api/platform/v1/categories
Request Body
| Field | Data Type | Description | Required | 
|---|---|---|---|
| name | string | Name of the category. | |
| visible_on_store_front | boolean | Whether this category should be shown in storefront. | |
| category_id | string | UUID of the category. If category needs to be created as subcategory, this is required. If none specified, category will be created at root level. | 
curl command
  curl 'http://localhost:3000/api/platform/v1/categories' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer in9euodknhaOS7dHHHohvFGGbgfK7_LjD_o9PLKl5AI' \
  -H 'Content-Type: application/json' \
  --data-raw '{"name":"Temp","visible_on_store_front":false,"used_for_components":false,"category_id":"16f1301d-6852-4cfc-a2e5-9f17f466dd58"}'
Response Body
response data object is category object
  {
    "status": "success",
    "data": {
      "id": "38a7999b-85f2-426b-b604-672c51885fe1",
      "name": "Temp",
      "sub_categories_count": 0,
      "products_count": 0,
      "visible_on_store_front": false,
      "used_for_components": false,
      "metadata": null,
      "extradata": null,
      "created_at": "2023-04-17T10:22:56.956Z",
      "updated_at": "2023-04-17T10:22:56.956Z",
      "account_id": "a9f7ef20-dc03-494a-9db2-cbc43ff2f564"
    }
  }
Get Category¶
 GET /api/platform/v1/categories/{id}
curl command
Response Body
This api responds with data as category object.
Update Category¶
 PATCH /api/platform/v1/categories/{id} name, visible_on_store_front and used_for_components fields can be updated.
curl command
curl 'http://localhost:3000/api/platform/v1/categories/acdab54b-6dd3-4200-993d-5399267a3ec9' \
  -X 'PATCH' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer _DB2IKB-TRiQrL8Fh9d-TxvkZF_xxvR4OeiOLv6hai4' \
  -H 'Content-Type: application/json' \
  --data-raw '{"name":"Men","visible_on_store_front":true,"used_for_components":true}'
Response Body
response data object is category object
  {
    "status": "success",
    "data": {
      "id": "acdab54b-6dd3-4200-993d-5399267a3ec9",
      "name": "Men",
      "sub_categories_count": 0,
      "products_count": 0,
      "visible_on_store_front": false,
      "used_for_components": false,
      "metadata": null,
      "extradata": null,
      "created_at": "2023-04-17T10:22:56.956Z",
      "updated_at": "2023-04-17T10:22:56.956Z",
      "account_id": "a9f7ef20-dc03-494a-9db2-cbc43ff2f564"
    }
  }
Delete Category¶
 DELETE /api/platform/v1/categories/{id} Only categories without any sub categories or products can be deleted.
curl command
Response Body
data is Category object that is deleted.
{
  "status": "success",
  "data": {
    "id": "abb3793f-8dcf-41dd-9ce8-3e5f25bea867",
    "name": "Temp",
    "sub_categories_count": 0,
    "products_count": 0,
    "visible_on_store_front": false,
    "used_for_components": false,
    "metadata": null,
    "extradata": null,
    "created_at": "2023-04-17T11:15:59.287Z",
    "updated_at": "2023-04-17T11:15:59.287Z",
    "account_id": "a9f7ef20-dc03-494a-9db2-cbc43ff2f564"
  }
}
Category Roots¶
 GET /api/platform/v1/categories/roots
Provides categories at the root level.
curl command
Response Body
Same as list api response
Category Products¶
 GET /api/platform/v1/categories/{id}/products
Provides categories at the root level.
curl command
Response Body
Same as product list api response
Sub Categories¶
 GET /api/platform/v1/categories/{id}/sub_categories Provides categories with in a category.
curl command
Response Body
Same as list api response
Move SubCategories¶
 POST /api/platform/v1/categories/move_categories
Provides a way to move an array of categories from a source to a destination category.
Request Body
| Field | Data Type | Description | Required | 
|---|---|---|---|
| categories | string array | UUID of the categories that should be moved. | |
| target_category_id | string | UUID of the target category to which categories will be moved to. | 
curl command
curl 'http://localhost:3000/api/platform/v1/categories/move_categories' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer VmpqQlsHrnR2tnvMCtsY95BeImAcIwtZOpaDdrH8EGQ' \
  -H 'Content-Type: application/json' \
  --data-raw '{"categories":["16f1301d-6852-4cfc-a2e5-9f17f466dd58"],"target_category_id":"d6e162e6-695b-4de8-b6e0-3bcc1e83cb9c"}'
Response Body
If operation is successful data object will be returned as null.
Move Products¶
 POST /api/platform/v1/categories/move_products
Provides a way to move an array of products from a source to a destination category.
Request Body
| Field | Data Type | Description | Required | 
|---|---|---|---|
| product_ids | string array | UUID of the products that should be moved. | |
| target_category_id | string | UUID of the target category to which categories will be moved to. | 
curl command
curl 'http://localhost:3000/api/platform/v1/categories/move_products' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer VmpqQlsHrnR2tnvMCtsY95BeImAcIwtZOpaDdrH8EGQ' \
  -H 'Content-Type: application/json' \
  --data-raw '{"product_ids":["95457d12-a175-407e-9522-e7004f71b6df"],"target_category_id":"725cad6c-0bf9-44ee-89d9-5594e6e69fc5"}'
Response Body
If operation is successful data object will be returned as null.
Reorder Products¶
 POST /api/platform/v1/categories/reorder_products
Provides a way to arrange positioning of products within a category.
Request Body
| Field | Data Type | Description | Required | 
|---|---|---|---|
| category_id | string | UUID of the cateogory within which product positions need to be arranged. | |
| items | object array | array of item objects, each with product id and position value. | 
curl command
curl 'http://localhost:3000/api/platform/v1/categories/reorder_products' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer VmpqQlsHrnR2tnvMCtsY95BeImAcIwtZOpaDdrH8EGQ' \
  -H 'Content-Type: application/json' \
  --data-raw '{"category_id":"725cad6c-0bf9-44ee-89d9-5594e6e69fc","items":[{"id":"6f50c995-930e-46a3-8e6e-f8617a239eba","position":0},{"id":"95457d12-a175-407e-9522-e7004f71b6df","position":1}]}'
Response Body
If operation is successful data object will be returned as null.
Reorder Categories¶
 POST /api/platform/v1/categories/reorder_categories
Provides a way to arrange positioning of sub categories within a category. The behaviour of this api is same as reorder products except that item.id should be category id.
Request Body
| Field | Data Type | Description | Required | 
|---|---|---|---|
| category_id | string | UUID of the cateogory within which product positions need to be arranged. | |
| items | object array | array of item objects, each with category id and position value. | 
curl command
curl 'http://localhost:3000/api/platform/v1/categories/reorder_categories' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer VmpqQlsHrnR2tnvMCtsY95BeImAcIwtZOpaDdrH8EGQ' \
  -H 'Content-Type: application/json' \
  --data-raw '{"category_id":"725cad6c-0bf9-44ee-89d9-5594e6e69fc","items":[{"id":"6f50c995-930e-46a3-8e6e-f8617a239eba","position":0},{"id":"95457d12-a175-407e-9522-e7004f71b6df","position":1}]}'
Response Body
If operation is successful data object will be returned as null.
Collection¶
Collection is way to group related products, e.g. for a fashion store, collection could be named "Winter Clothing" and all relevant prducts for winter to be listed there
stateDiagram-v2
    A: Product
    B: Product
    C: Product
    D: Product
    E: Product
    F: Product
    G: Product    
    Winter --> A
    Winter --> B
    Winter --> C
    Beach --> D
    Beach --> E
    Beach --> F
    Beach --> GCollection Object¶
Below is the json representation of the collection object, followed by a data table
{
  "id": "fa2c1344-e514-4692-87c6-141755cc0fc2",
  "name": "Winter",
  "products_count": 0,
  "created_at": "2023-04-18T11:16:16.709Z",
  "updated_at": "2023-04-18T11:16:16.709Z",
  "position": 0
}
Fields¶
| Field | Data Type | Description | 
|---|---|---|
| id | string | UUID of the collection. | 
| name | string | Name of the collection. | 
| products_count | integer | Number of products in the collection. | 
| position | integer | Position of the product in the collection. | 
API¶
List Collections¶
 GET /api/platform/v1/collections
The result set contains all collections and there wont be any pagination.
curl command
Response Body
This api responds with array of collection objects.
  {
    "status": "success",
    "data": [
      {
        "id": "fa2c1344-e514-4692-87c6-141755cc0fc2",
        "name": "Winter",
        "products_count": 0,
        "created_at": "2023-04-18T11:16:16.709Z",
        "updated_at": "2023-04-18T11:16:16.709Z",
        "position": 0
      },
      {
        "id": "108df094-147c-49e6-b889-e75505733432",
        "name": "Beach",
        "products_count": 0,
        "created_at": "2023-04-18T11:16:21.662Z",
        "updated_at": "2023-04-18T11:16:21.662Z",
        "position": 1
      }
    ]
  }
Search Collections¶
 POST /api/platform/v1/collections/search
Search is primarily based on name of the collection.
curl command
Response Body
This api responds with array of collection objects.
{
  "status": "success",
  "data": [
    {
      "updated_at": "2023-04-18T11:16:16.709Z",
      "name": "Winter",
      "products_count": 0,
      "created_at": "2023-04-18T11:16:16.709Z",
      "id": "fa2c1344-e514-4692-87c6-141755cc0fc2"
    }
  ],
  "pagination": {
    "total_count": 1,
    "current_page": 1,
    "total_pages": 1,
    "window": 4,
    "breakdown": [
      {
        "kind": "inner",
        "url": "/api/platform/v1/collections/search?query=win",
        "page": 1
      }
    ]
  }
}
Create Collection¶
 POST /api/platform/v1/collections
curl command
Response Body
Response data object is collection object
Get Collection¶
 GET /api/platform/v1/collections/{id}
curl command
Response Body
Response data object is collection object
Update Collection¶
 PATCH /api/platform/v1/collections/{id}
curl command
Response Body
Response data object is collection object
Delete Collection¶
 DELETE /api/platform/v1/collections/{id}
curl command
Response Body
Response data object is collection object
Collection Products¶
 GET /api/platform/v1/collections/{id}/products
Provides categories at the root level.
curl command
Response Body
Same as product list api response
Reorder Collections¶
 POST /api/platform/v1/collections/reorder
Provides a way to arrange positioning of collections.
Request Body
| Field | Data Type | Description | Required | 
|---|---|---|---|
| items | object array | array of item objects, each with collection id and position value. | 
curl command
curl 'http://localhost:3000/api/platform/v1/collections/reorder' \
    -H 'Accept: application/json' \
    -H 'Authorization: Bearer CnHehzdH0YC3YZJiAqPQJ4wLU5AiWAfnWq4KWPY-49o' \
    -H 'Content-Type: application/json' \
    --data-raw '{"items":[{"id":"108df094-147c-49e6-b889-e75505733432","position":0},{"id":"fa2c1344-e514-4692-87c6-141755cc0fc2","position":1}]}'
Response Body
If operation is successful data object will be returned as {}.
Reorder Products¶
 POST /api/platform/v1/collections/{id}/reorder_products
Provides a way to arrange positioning of products within a collection.
Request Body
| Field | Data Type | Description | Required | 
|---|---|---|---|
| items | object array | array of item objects, each with product id and position value. | 
curl command
  curl 'http://localhost:3000/api/platform/v1/collections/fa2c1344-e514-4692-87c6-141755cc0fc2/reorder_products' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer CnHehzdH0YC3YZJiAqPQJ4wLU5AiWAfnWq4KWPY-49o' \
  -H 'Content-Type: application/json' \
  --data-raw '{"items":[{"id":"6f50c995-930e-46a3-8e6e-f8617a239eba","position":0},{"id":"95457d12-a175-407e-9522-e7004f71b6df","position":1}]}'
Response Body
If operation is successful data object will be returned as {}.
``` {"status":"success","data":{}}
Add Products¶
 POST /api/platform/v1/collections/{id}/add_products
Add array of products to a collection.
Request Body
| Field | Data Type | Description | Required | 
|---|---|---|---|
| product_ids | string array | array of product ids. | 
curl command
  curl 'http://localhost:3000/api/platform/v1/collections/fa2c1344-e514-4692-87c6-141755cc0fc2/add_products' \
    -H 'Accept: application/json' \
    -H 'Authorization: Bearer CnHehzdH0YC3YZJiAqPQJ4wLU5AiWAfnWq4KWPY-49o' \
    -H 'Content-Type: application/json' \
    --data-raw '{"product_ids":["95457d12-a175-407e-9522-e7004f71b6df","6f50c995-930e-46a3-8e6e-f8617a239eba"]}'
Response Body
If operation is successful data object will be returned as {}.
Remove Products¶
 POST /api/platform/v1/collections/{id}/remove_products
Remove array of products from a collection.
Request Body
| Field | Data Type | Description | Required | 
|---|---|---|---|
| product_ids | string array | array of product ids. | 
curl command
  curl 'http://localhost:3000/api/platform/v1/collections/fa2c1344-e514-4692-87c6-141755cc0fc2/remove_products' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer CnHehzdH0YC3YZJiAqPQJ4wLU5AiWAfnWq4KWPY-49o' \
  -H 'Content-Type: application/json' \
  --data-raw '{"product_ids":["6f50c995-930e-46a3-8e6e-f8617a239eba","95457d12-a175-407e-9522-e7004f71b6df"]}'