Back to Website
Product Documentation Developers Integration Hub Customer API - Search Products

Customer API - Search Products

In this guide, we're going to take you through how you can fetch and search products through the Kodaris API.

Video Overview:

https://youtu.be/G7NO0aeh6q4?si=ASm1NOdi4lZ-Y_45
  1. Sign In
    • Note: Skip this step if you want to get data as a guest user.
    • In order to get customer specific information, you will want to sign in to an account through the API.
    • Call the endpoint: POST / api/user/customer/apiKeyLogin
      • Headers
        • Accept - application/json
        • Content-Type - application/json
      • Body
        • apiKey - the api key of your api user.
      • Response
        • A response will be returned indicating whether the login was successful or not. The response will also contain your userSessionApiKey that you will need to use on future requests to get responses back as a authenticated user.
  2. Fetch an Auth Token
    • Note: Skip this step if you want to get data as a guest user.
    • You'll need an authorization token for any API requests you make to the Kodaris API.
    • Fetch one using the endpoint: GET / api/user/customer/authToken
      • Headers
        • Accept - application/json
        • Content-Type - application/json
        • userSessionApiKey - the userSessionApiKey from the /apiKeyLogin endpoint response
      • Response
        • The returned response will contain your auth token that you will need to use on future requests.
  3. Search Products
    • Now you can search products as an authenticated user.
    • Send an API request to endpoint: GET api/user/search/product/text
      • Headers
        • Accept - application/json
        • Content-Type - application/json
        • userSessionApiKey - the userSessionApiKey from the /apiKeyLogin endpoint response
          • (Note: skip this header if you want to get data as a guest user.)
        • X-CSRF-TOKEN - the auth token from the /authToken endpoint response
          • (Note: skip this header if you want to get data as a guest user.)
      • Query Params
        • searchString - ceilings
          • Sending this query parameter returns products related to the search string sent in. E.g. 'ceilings' will return products related to ceilings.
        • from - 1
          • Sending this query parameter specifies the which page of results you would like returned, e.g. sending 1 will return you the first results page.
        • facets - fg_brand|fg_brand_usg
          • If you would like to filter for certain products, for example USG brand products, just send in the facet code like shown above. These filters and facet codes are returned in the response.
      • Response
        • The returned response will include products and filters.

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;

// search products
var searchRes = kd.http.fetch({
  method: 'GET',
  url: 'https://content.kodaris.com/api/user/search/product/text',
  version: 2,
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'userSessionApiKey': userSessionApiKey,
    'X-CSRF-TOKEN': token
  },
  queryParams: {
    "searchString": "ceilings",
    "from": 1,
    "facets": "fg_Edge|fg_Edge_fineline"
  }
});

kd.log('searchRes', searchRes);

-> response ->
{
    "status" : 200,
    "errors" : null,
    "body" : {
      "code" : 200,
      "success" : true,
      "errors" : { },
      "messages" : { },
      "data" : {
        "size" : 24,
        "number" : 1,
        "totalElements" : 11,
        "isLast" : true,
        "totalPages" : 1,
        "isFirst" : true,
        "hasPrevious" : false,
        "hasNext" : false,
        "numberOfElements" : 11,
        "offset" : null,
        "content" : {
          "0" : {
            "productID" : 7096,
            "code" : "114CEMENT",
            "seoCode" : "114CEMENT",
            "name" : "9/16 in x 15/16 in x 12 ft USG Donn Brand Fineline 1/8 DXFF Wall Angle - M9",
            "description" : " This unique, economical and simply installed system provides a monolithic ceiling look with every benefit of a standard exposed grid. The Donn® Brand Fineline® 1/8 DXFF™ Acoustical Suspension System allows for easy ceiling access, while its narrow slotted profile hides the suspension system behind acoustical panels, yielding a smooth, clean ceiling plane with minimal exposed metal.     Applications        All interior general-use areas        Details        Color: Flat White    Material Type: Hot-Dipped Galvanized Steel    ",
            "unitStock" : null,
            "smallImage" : "https://s3.amazonaws.com/commerce.kodaris.com/product/SM-USG_M9.jpg",
            "mediumImage" : "https://s3.amazonaws.com/commerce.kodaris.com/product/MD-USG_M9.jpg",
            "largeImage" : "https://s3.amazonaws.com/commerce.kodaris.com/product/LG-USG_M9.jpg",
            "unitSell" : null,
            "unitPrice" : 0,
            "unitPriceConversionFactor" : null,
            "unitContainer" : null,
            "priceCalculationType" : null,
            "url" : "https://content.kodaris.com/product/114CEMENT",
            "manufacturerCode" : null,
            "manufacturerProductCode" : null,
            "displayFootageCalculator" : false,
            "directShipped" : false,
            "productType" : null
          },
          "1" : {
            "productID" : 6782,
            "code" : "AXL7540",
            "seoCode" : "AXL7540",
            "name" : "1 25/32 in x 10 ft USG Donn Brand Fineline 1/8 DXFF 9/16 in Acoustical Suspension System Intermediate Duty Main Tee - DXFF2930",
            "description" : " This unique, economical and simply installed system provides a monolithic ceiling look with every benefit of a standard exposed grid. The Donn® Brand Fineline® 1/8 DXFF™ Acoustical Suspension System allows for easy ceiling access, while its narrow slotted profile hides the suspension system behind acoustical panels, yielding a smooth, clean ceiling plane with minimal exposed metal.     Applications        All interior general-use areas        Details        Color: Flat White    Material Type: Hot-Dipped Galvanized Steel        Features        Narrow-profile, slotted grid system with 1/8\" reveal provides streamlined appearance    Reveal accommodates partition attachments and pendant-mounted light fixtures    Mitered intersections offer a clean, tailored appearance    Meets or exceeds all national code requirements,including seismic    Optional integrated air diffuser    Accepts metal ceiling panels for ceiling-area accents without changing grid system    Custom color available    ICC-ES evaluated approach to seismic design installations (ICC-ESR-1222)    Standard components available in Imperial and Metric sizes    Available with High Recycled Content (HRC)    ",
            "unitStock" : null,
            "smallImage" : "https://s3.amazonaws.com/commerce.kodaris.com/product/SM-USG_DXFF2930.jpg",
            "mediumImage" : "https://s3.amazonaws.com/commerce.kodaris.com/product/MD-USG_DXFF2930.jpg",
            "largeImage" : "https://s3.amazonaws.com/commerce.kodaris.com/product/LG-USG_DXFF2930.jpg",
            "unitSell" : null,
            "unitPrice" : 266.4599914550781,
            "unitPriceConversionFactor" : null,
            "unitContainer" : null,
            "priceCalculationType" : null,
            "url" : "https://content.kodaris.com/product/AXL7540",
            "manufacturerCode" : null,
            "manufacturerProductCode" : "DXFF2930",
            "displayFootageCalculator" : false,
            "directShipped" : false,
            "productType" : null
          }
... omitted for brevity
        },
        "filters" : {
          "0" : {
            "code" : "facets",
            "name" : "Acoustical Edge",
            "value" : "fg_Edge",
            "attributes" : {
              "0" : {
                "name" : "Fineline",
                "count" : 11,
                "active" : true,
                "value" : "fg_Edge|fg_Edge_fineline",
                "categoryOrder" : 0
              },
              "1" : {
                "name" : "Fineline Bevel",
                "count" : 7,
                "active" : false,
                "value" : "fg_Edge|fg_Edge_finelineBevel",
                "categoryOrder" : 0
              },
              "2" : {
                "name" : "Reveal Panel",
                "count" : 2,
                "active" : false,
                "value" : "fg_Edge|fg_Edge_revealpanel",
                "categoryOrder" : 0
              },
              "3" : {
                "name" : "Shadowline",
                "count" : 8,
                "active" : false,
                "value" : "fg_Edge|fg_Edge_shadowline",
                "categoryOrder" : 0
              },
... omitted for brevity
In this article