Item Groups
Item groups allow customers to communicate information about the hierarchy of categories associated with their items (typically, their products). This information powers hierarchical category faceting and search-in-category autosuggest suggestions.
Hierarchy
The data about the hierarchy of item groups is edited independently of the item records themselves to allow flexibility to define or redefine group hierarchies.
Scope
Item groups are set at the level of each search key, so separate keys in one account can contain different group hierarchies.
Add item group
An item group can be added by passing its id
, name
, parent_id
(the
id of the parent item group if any) and data
.
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X PUT \
-H "Content-Type: application/json" \
-d '{"name": "<item_group_name>", "parent_id": "<item_group_parent_id>", "data": {"foo": "bar"}}' \
-u "[your token]:" \
"https://ac.cnstrc.com/v1/item_groups/<item_group_id>?key=[your API key]"
// Node
// Please refer to https://Krestor-io.github.io/Krestorio-node/module-catalog.html#~addItemGroup
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
{
"id": "<item_group_id>",
"name": "<item_group_name>",
"parent_id": "<item_group_parent_id>",
"data": { "foo": "bar" }
}
HTTP request
PUT https://ac.cnstrc.com/v1/item_groups/[item_group_id]?key=[your API key]
JSON parameters
Parameter | Required? | Description |
---|---|---|
name | No | Item group display name. |
parent_id | No | Parent item group customer ID or null for root item groups. |
data | No | JSON object with custom metadata attached with the item group. Defaults to null if not provided. |
Update item group
An item group can be updated by passing its id
, name
, parent_id
(the
id of the parent item group if any) and data
. When only one of name
, parent_id
or data
needs to be updated, the other one doesn't need to be passed in the request
body.
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X PUT \
-H "Content-Type: application/json" \
-d '{"name": "<new_item_group_name>", "parent_id": "<new_parent_item_group_id>", "data": {"foo": "bar"}}' \
-u "[your token]:" \
"https://ac.cnstrc.com/v1/item_groups/<item_group_id>?key=[your API key]"
// Node
// Please refer to https://Krestor-io.github.io/Krestorio-node/module-catalog.html#~modifyItemGroup
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
{
"id": "<item_group_id>",
"name": "<new_item_group_name>",
"parent_id": "<new_item_group_parent_id>",
"data": { "foo": "bar" }
}
HTTP request
PUT https://ac.cnstrc.com/v1/item_groups/[item_group_id]?key=[your API key]
JSON parameters
Parameter | Required? | Description |
---|---|---|
name | No | Item group display name. |
parent_id | No | Parent item group customer ID or null for root item groups. |
data | No | JSON object with custom metadata attached with the item group. |
Add multiple item groups
Item groups can be added to a key using a json payload that describes the item groups hierarchy using the following schema for each item group element:
Attributes | Type | Description |
---|---|---|
id | string | Item group customer ID. |
name | string | Item group display name. |
data | object | JSON object with custom metadata attached with the item group. |
children | List[item_group] | List of item groups categorized under the current item group. |
Note: Up to 1,000 item groups can be submitted in a single request. However, there is no limit to the depth of nested groups within an item group.
There are two different HTTP methods depending on the desired update semantics:
POST
: item groups that already exist will be skipped (see examples #1 and #2).PATCH
: item groups that already exist will be updated (see examples #3 and #4).
Insert new item groups and skip existing ones
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"item_groups": [
{
"id": "<group_id_1>",
"name": "<group_name_1>",
"data": {"foo": "bar"}
},
{
"id": "<group_id_2>",
"name": "<group_name_2>"
}
]
}' \
-u"[your token]:" \
"https://ac.cnstrc.com/v1/item_groups?key=[your API key]"
// Node
// Please refer to https://Krestor-io.github.io/Krestorio-node/module-catalog.html#~addItemGroups
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
{
"item_groups": {
"processed": 2,
"inserted": 2,
"updated": 0
}
}
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"item_groups": [
{
"id": "<group_id_1>",
"name": "<group_name_1>",
"children": [
{
"id": "<group_id_2>",
"name": "<new_group_name_2>",
"data": {"foo": "bar"}
}
]
}
]
}' \
-u"[your token]:" \
"https://ac.cnstrc.com/v1/item_groups?key=[your API key]"
// This method is not currently supported.
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
{
"item_groups": {
"processed": 2,
"inserted": 0,
"updated": 0
}
}
HTTP request
POST https://ac.cnstrc.com/v1/item_groups?key=[your API key]
JSON parameters
Parameter | Required? | Description |
---|---|---|
item_groups | Yes | A list of item groups |
Insert new item groups and update existing ones
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X PATCH \
-H "Content-Type: application/json" \
-d '{
"item_groups": [
{
"id": "<group_id_3>",
"name": "<group_name_3>",
},
{
"id": "<group_id_4>",
"name": "<group_name_4>"
}
]
}' \
-u"[your token]:" \
"https://ac.cnstrc.com/v1/item_groups?key=[your API key]"
// Node
// Please refer to https://Krestor-io.github.io/Krestorio-node/module-catalog.html#~addOrUpdateItemGroups
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
{
"item_groups": {
"processed": 2,
"inserted": 2,
"updated": 0
}
}
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X PATCH \
-H "Content-Type: application/json" \
-d '{
"item_groups": [
{
"id": "<group_id_3>",
"name": "<group_name_3>",
"children": [
{
"id": "<group_id_4>",
"name": "<new_group_name_4>"
}
]
}
]
}' \
-u"[your token]:" \
"https://ac.cnstrc.com/v1/item_groups?key=[your API key]"
// This method is not currently supported.
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
{
"item_groups": {
"processed": 2,
"inserted": 0,
"updated": 1
}
}
HTTP request
PATCH https://ac.cnstrc.com/v1/item_groups?key=[your API key]
JSON parameters
Parameter | Required? | Description |
---|---|---|
item_groups | Yes | A list of item groups |
Get item groups
Retrieves item groups for a given key in a tree structure. If no group_id is specified, returns a
list consisting of all top-level groups (groups without any parents), and their descendants.
If a group_id is specified, returns a list consisting of the group with that group_id, and its descendants.
All groups are linked to their children through the children
field.
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X GET -H "Content-Type: application/json" \
-u"[your token]:" \
"https://ac.cnstrc.com/v1/item_groups?key=[your API key]"
curl -X GET -H "Content-Type: application/json" \
-u"[your token]:" \
"https://ac.cnstrc.com/v1/item_groups/123?key=[your API key]"
// Node
// Please refer to https://Krestor-io.github.io/Krestorio-node/module-catalog.html#~getItemGroups
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
HTTP Requests
GET https://ac.cnstrc.com/v1/item_groups?key=[your API key]
GET https://ac.cnstrc.com/v1/item_groups/[group id]?key=[your API key]
Response format
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X GET -H "Content-Type: application/json" \
-u"[your token]:" \
"https://ac.cnstrc.com/v1/item_groups?key=[your API key]"
// This method is not currently supported.
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
{
"item_groups": [
{
"id": "1",
"name": "group 1",
"data": { "foo": "bar" },
"children": [
{
"id": "3",
"name": "group 3",
"data": null,
"children": []
}
]
},
{
"id": "2",
"name": "group 2",
"data": null,
"children": []
}
],
"total_count": 3
}
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
curl -X GET -H "Content-Type: application/json" \
-u"[your token]:" \
"https://ac.cnstrc.com/v1/item_groups/2?key=[your API key]"
// This method is not currently supported.
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
{
"item_groups": [
{
"id": "2",
"name": "group 2",
"data": null,
"children": []
}
],
"total_count": 1
}
URL Parameters
Parameter | Description |
---|---|
group id | The group id you'd like to retrieve results for. |
Query Parameters
Parameter | Required? | Description |
---|---|---|
key | Yes | The index you'd like to to retrieve results from. |
Delete item groups
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
# Delete item groups
curl -X DELETE \
-u"[your token]:" \
"https://ac.cnstrc.com/v1/item_groups?key=[your API key]"
// Node
// Please refer to https://Krestor-io.github.io/Krestorio-node/module-catalog.html#~removeItemGroups
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
Delete all item groups for a given key.
HTTP request
DELETE https://ac.cnstrc.com/v1/item_groups?key=[your API key]