In this guide, we're going to take you through how you can fetch a category, its products and filters, through the Kodaris API.
Video overview:
Example
// Login to our account
var loginRes = kd.http.fetch({
method: 'POST',
url: 'https://content.kodaris.com/api/user/customer/apiKeyLogin',
version: 2,
body: {
apiKey: 'xxxx'
},
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
});
// keep our session token for future requests
var userSessionApiKey = loginRes.body.data.userSessionApiKey;
// get CRSF token for requests
var tokenRes = kd.http.fetch({
method: 'GET',
url: 'https://content.kodaris.com/api/user/customer/authToken',
version: 2,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'userSessionApiKey': userSessionApiKey
}
});
// keep our token for future requests
var token = tokenRes.body.data;
// get customer side category
var categoryRes = kd.http.fetch({
method: 'GET',
url: 'https://content.kodaris.com/api/user/category/ceilings',
version: 2,
queryParams: {
"includeFilters": true,
"facets": 'fg_brand|fg_brand_usg',
"page": 1
},
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'userSessionApiKey': userSessionApiKey,
'X-CSRF-TOKEN': token
}
});
kd.log('categoryRes', categoryRes);
-> response ->
{
"status" : 200,
"errors" : null,
"body" : {
"code" : 200,
"success" : true,
"errors" : { },
"messages" : { },
"data" : {
"size" : 24,
"number" : 2,
"totalElements" : 134,
"isLast" : false,
"totalPages" : 6,
"isFirst" : false,
"hasPrevious" : true,
"hasNext" : true,
"numberOfElements" : 134,
"offset" : 2,
"content" : {
"0" : {
"productID" : 9535,
"code" : "ZAMAC02814",
"seoCode" : "ZAMAC02814",
"name" : "1 in x 1/2 in x 3/4 in x 10 ft USG Suspension System U Molding - US12",
"description" : " All of the tools you need to install your suspension system quickly and easily. Donn® Brand Acoustical Suspension System Accessories; provides everything you need to install your suspension system. With everything from galvanized hanger wire to stabilizer bars to cross tee hole punches, your ceiling project is sure to go quickly and smoothly. Details Color: White Includes 50 pieces per carton 500 linear feet per carton ",
"unitStock" : null,
"smallImage" : "https://s3.amazonaws.com/commerce.kodaris.com/product/SM-USG_U_Channel.jpg",
"mediumImage" : "https://s3.amazonaws.com/commerce.kodaris.com/product/MD-USG_U_Channel.jpg",
"largeImage" : "https://s3.amazonaws.com/commerce.kodaris.com/product/LG-USG_U_Channel.jpg",
"unitSell" : null,
"unitPrice" : 290.1499938964844,
"unitPriceConversionFactor" : null,
"unitContainer" : null,
"priceCalculationType" : null,
"url" : "https://content.kodaris.com/product/ceilings/ZAMAC02814",
"manufacturerCode" : null,
"manufacturerProductCode" : null,
"displayFootageCalculator" : false,
"directShipped" : false,
"productType" : null
},
... omitted for brevity
},
"filters" : {
"0" : {
"type" : "link",
"name" : "Categories",
"attributes" : {
"0" : {
"code" : "ceiling_grid_trim",
"name" : "Ceiling Grid & Trim",
"count" : 80,
"url" : "/category/ceilings/ceiling_grid_trim",
"categoryOrder" : 0,
"mediumImage" : null
},
"1" : {
"code" : "ceiling_acoustical",
"name" : "Acoustical Tile",
"count" : 28,
"url" : "/category/ceilings/Acoustical Tiles",
"categoryOrder" : 0,
"mediumImage" : null
},
"2" : {
"code" : "ceiling_tile_panels",
"name" : "Ceiling Tile & Panels",
"count" : 26,
"url" : "/category/ceilings/ceiling_tile_panels",
"categoryOrder" : 0,
"mediumImage" : null
}
}
},
"1" : {
"code" : "inStockAtWarehouse",
"showCounts" : false,
"name" : "Usually Ships Next Day",
"type" : "checkbox",
"attributes" : {
"0" : {
"name" : "Yes",
"active" : false,
"value" : "EV"
}
}
},
"2" : {
"code" : "facets",
"name" : "Acoustical Edge",
"value" : "fg_Edge",
"attributes" : {
"0" : {
"name" : "Fineline",
"count" : 11,
"active" : false,
"value" : "fg_Edge|fg_Edge_fineline",
"categoryOrder" : 0
},
"1" : {
"name" : "Fineline Bevel",
"count" : 8,
"active" : false,
"value" : "fg_Edge|fg_Edge_finelineBevel",
"categoryOrder" : 0
},
"2" : {
"name" : "Shadowline",
"count" : 10,
"active" : false,
"value" : "fg_Edge|fg_Edge_shadowline",
"categoryOrder" : 0
},
"3" : {
"name" : "Shadowline Bevel",
"count" : 2,
"active" : false,
"value" : "fg_Edge|fg_Edge_shadowlineBevel",
"categoryOrder" : 0
},
"4" : {
"name" : "Shadowline Tapered",
"count" : 9,
"active" : false,
"value" : "fg_Edge|fg_Edge_shadowlineTapered",
"categoryOrder" : 0
},
"5" : {
"name" : "Square Edge",
"count" : 12,
"active" : false,
"value" : "fg_Edge|fg_Edge_squareEdge",
"categoryOrder" : 0
}
},
"productDisplay" : false,
"valuesOrderBy" : "nameAsNumber"
},
"5" : {
"code" : "facets",
"name" : "Product Brands",
"value" : "fg_brand",
"attributes" : {
"0" : {
"name" : "Cemco",
"count" : 1,
"active" : false,
"value" : "fg_brand|fg_brand_cemco",
"categoryOrder" : 0
},
"1" : {
"name" : "Rockfon",
"count" : 42,
"active" : false,
"value" : "fg_brand|fg_brand_rockfon",
"categoryOrder" : 0
},
"2" : {
"name" : "CertainTeed",
"count" : 44,
"active" : false,
"value" : "fg_brand|fg_brand_certainTeed",
"categoryOrder" : 0
},
"3" : {
"name" : "USG",
"count" : 134,
"active" : true,
"value" : "fg_brand|fg_brand_usg",
"categoryOrder" : 0
}
},
"productDisplay" : true,
"valuesOrderBy" : "categoryOrder"
}
... omitted for brevity
},
"sort" : "",
"searchString" : ""
}
}
}