Skip to content

Product Category

edyywang edited this page Jun 22, 2017 · 14 revisions

Prepare Product Category data

Product Category API is to map which product belongs to which category. You need to prepare Category ID and Product ID data.

Category ID is from appierRtCategoryIDs of the type_listpage event:

var appierRtCategoryIDs = ["ID3C","IDNotebook"]; 

Product ID is from appierRtItemId of the type_product event:

var appierRtItemId = "productID1"; 

In this example, you could map product "productID1" belongs to category "IDNotebook"


API Methods

For Product Category data, you could:


Query All Product Category Resources

You can use the API to get all available product-category resources you can upload product and category mapping info to. The result is the list of URLs with site IDs, for example "URL": "/api_upload/v1/product-category/demo.com.tw", that you can upload the product and category mapping info to that site ID, demo.com.tw.

API Information

Name Value
HTTP Method GET
URL https://${AIXON-API-HOST}/api_upload/v1/product-category

Example:

Request

curl -k -v "https://${AIXON-API-HOST}/api_upload/v1/product-category" \
     -H "x-api-key: ${api-key}" \
     -H "Content-Type: application/json; charset=utf-8"

Response

{
  "message": [
    {
      "DESCRIPTION": "GET all product-category resources", 
      "SUPPORT_METHODS": [
        "GET"
      ], 
      "URL": "/api_upload/v1/product-category"
    }, 
    {
      "DESCRIPTION": "Upload product category mapping for demo.com.tw", 
      "SUPPORT_METHODS": [
        "PUT"
      ], 
      "URL": "/api_upload/v1/product-category/demo.com.tw"
    }
  ], 
  "status": "success"
}

Update Product Category Resource

This API will update product and product category relationship based on resourceId. The resourceId refers to a tracking website.

Before you start to update product and category mapping, you should have the resourceId (the siteid provided to you from Appier Technical Support team when you start to implement tracking tag in your website). If you don’t know the resourceId, please contact your account manager.

API Information

Name Value
HTTP Method PUT
URL https://${AIXON-API-HOST}/api_upload/v1/product-category/${resourceId}

Example:

Request

curl -k -v "https://${AIXON-API-HOST}/api_upload/v1/product-category/demo.com.tw" \
     -H "x-api-key: ${api-key}" \
     -H "Content-Type: application/json; charset=utf-8" \
     -d '{
  "header": ["category_id", "product_id"],
  "data": [
               ["c001", "p001"],
               ["c002", "p002"],
               ["c003, 004", "p003"]
        ]
      }'

Response

{
 "message": {
   "RESOURCE_ID": "demo.com.tw",
   "STATUS": "RECEIVED"
 },
 "status": "success"
}

Description

You can use PUT /product-category/{resouceId} to update the product and category mapping. AIXON API supports CSV file upload or using JSON data to update product and category mapping. The following columns and orders are mandatory: category_id, product_id

Here below is the example of a product category mapping for http request body in JSON format:

{
	"header": ["category_id", "product_id"],
	"data": [
		["c001", "p001"],
		["c002", "p002"],
		["c003, 004", "p003"]
	]
}
  • octocat category_id must be the lowest level of category_id in the resourceId’s category hierarchy.
  • octocat product_id must be unique.
  • octocat product_id can map to multiple category id, use , to separate those ids and use " to quote them.