Category API
Category API is designed to be used for getting categories and sub-categories for supporting category based navigation and breadcrumb display in websites.
Categories :
/api/categories
This api returns the current and the immediate next level categories for the given catalog. This is useful when drilling down one specific category. Use the catCode parameter to restrict the categories and products to one sub category at any level.
| Parameter Name | Mandatory | Default | Sample Values | Comments |
|---|---|---|---|---|
|
locationId |
Yes |
1872 | Catalog Id As defined in CloudLSI | |
|
catCode |
No | |0| |
|0|40000| |
CategoryCode is used to get the data for the selected category level. Pass the exact data as returned by the API. |
|
rows |
No |
0 or 10 (read comments for more details) |
0 or 10 or 25 |
Rows will be set to 0 if there are more than 2 subcategories for the selected category. It will be set to 10 by default if there are less than 2 subcategory for the selected category |
Other parameters in the search api are also supported for filtering and faceting.
The category code and desc contains the complete drill down of the category the products are mapped to.
A sample value of catalogHierarchyCode for product with catalog code 513-AJB-A2F-6P-39 is
GÇ£|0|40000|GÇ¥, GÇ£|1|40000|41000|",
GÇ£|2|40000|41000|41300|", "|3|40000|41000|41300|41340|"
This means that the parent category is 40000, 2nd level subcategory is 41000, 3rd level subcategory is 41300 and the leaf level category is 41340.
The corresponding Descriptions are
"|0|Controls|",
"|1|Controls|Controls - Motor Control Starters, Contactors, & Renewal Pts|", "|2|Controls|Controls - Motor Control Starters, Contactors, & Renewal Pts|Motor Control Starters, Etc - Motor Cntrl Starters & Cntctrs|",
"|3|Controls|Controls - Motor Control Starters, Contactors, & Renewal Pts|Motor Control Starters, Etc - Motor Cntrl Starters & Cntctrs|Nema Combination Starters|GÇ¥
This follows the same pattern as the category code.
Usecases :
Get top level categories
url - /lsicloud/api/categories?locationId=1872
This will return the parent categories and the number of products in that category.
"CategoryHierarchyCode": [ "|0|40000|",
612212,
"|0|60000|",
532028, "|0|70000|", 321471, "|0|30000|", 268657, "|0|50000|", 189884, "|0|20000|", 125412, "|0|00000|", 108651, "|0|99000|", 39227, "|0|80000|", 35381, "|0|90000|",
32634, "|0|10000|", 31005
]
Navigating to a subcategory
The user selects the top-level category 40000 to drill down to the subcategory of this category. url - /lsicloud/api/categories?locationId=1872&catCode=|0|40000|
This API would return the second level categories under the selected category 40000.
"CategoryHierarchyCode": [ "|1|40000|41000|",
320525,
"|1|40000|42000|",
146382, "|1|40000|49000|", 69273, "|1|40000|46000|", 35237, "|1|40000|47000|", 19727, "|1|40000|43000|", 9541, "|1|40000|45000|", 6309, "|1|40000|48000|", 2989, "|1|40000|44000|", 2229
]
If the user selects a second level category to drill down to the 3rd level category pass the select category code to the api as
url - /lsicloud/api/categories?locationId=1872&catCode=|1|40000|41000| The API would return the 3rd level category for the selected category.
If there are no subcategories then the API would return the matching products. By default the API returns 10 products. Use rows parameter to request for more.
Category Hierarchy :
/api/categoryHierarchy
This api is used to get a complete representation of category hierarchy. The response contains a nested datastructure to walk through the hierarchy so that it is easy to find out the first levels of categories and its immediate subcategory. This api can be used to create a drill down tree UI as shown in the picture below.
Note :
All the categories API uses Tradeservice Taxonomy by default. This API's can be customized to work with any taxonomy.