Back to Website
Product Documentation Developers Integration Hub Customer API - Fetch Product Prices

Customer API - Fetch Pricing For Products

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

Video overview:

https://www.youtube.com/watch?v=UwqX4wraz_I
  1. Sign In
    • First, 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
    • 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. Fetch Product Prices
    • Now you can fetch pricing for products
    • Send an API request to GET /api/user/product/pricesByCodes
      • Headers
        • Accept - application/json
        • Content-Type - application/json
        • userSessionApiKey - the userSessionApiKey from the /apiKeyLogin endpoint response
        • X-CSRF-TOKEN - the auth token from the /authToken endpoint response
      • Query Parameters
        • productCodes - a comma delimited list of product codes that you want prices returned for, e.g. '12R09,cmmt82329,THR03681'
      • Response
        • The returned response will include price data for your list of product codes

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 pricing for products
var pricingRes = kd.http.fetch({
  method: 'GET',
  url: 'https://content.kodaris.com/api/user/product/pricesByCodes',
  version: 2,
  queryParams: {
    productCodes: '12R09,cmmt82329,THR03681'
  },
  body: {},
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'userSessionApiKey': userSessionApiKey,
    'X-CSRF-TOKEN': token
  }
});

kd.log('pricingRes', pricingRes);

-> response ->
{
  "status" : 200,
  "errors" : null,
  "body" : {
    "success" : true,
    "code" : 200,
    "messages" : { },
    "errors" : { },
    "data" : {
      "0" : {
        "code" : "12R09",
        "wholeUnit" : "MSF",
        "wholeUnitPrice" : null,
        "calculatedPrice" : null,
        "unitPrice" : null,
        "altPrice" : null,
        "specialOrder" : false,
        "erpDirectShipped" : false,
        "canPurchase" : true,
        "canPurchaseMessage" : null,
        "unitStock" : "PCS",
        "unitSell" : "PCS",
        "unitSellForPrice" : "PCS",
        "onSale" : false,
        "skuMessage" : null,
        "inStock" : true,
        "minimumOrderQuantity" : null,
        "maximumOrderQuantity" : null,
        "intervalOrderQuantity" : null,
        "mapPrice" : false,
        "priceBreaks" : { },
        "unitConversions" : { },
        "warehousesAvailability" : {
          "EV" : 345,
          "GJ" : 56,
          "SIL" : 6,
          "JT" : 624,
          "GYP" : 56,
          "Eng" : 520
        },
        "leadTimes" : { },
        "skuData" : {
          "0" : {
            "code" : "GJ",
            "name" : "Grand Rapids, MI",
            "region" : null,
            "city" : "Grand Rapids",
            "availability" : 56,
            "leadTimeInDays" : null,
            "status" : "O",
            "availableToOrder" : false,
            "skuMessage" : null,
            "inStock" : true,
            "directShipped" : false,
            "unitStandard" : null,
            "quantityOnOrder" : null
          },
          "1" : {
            "code" : "GYP",
            "name" : "Denver, CO",
            "region" : null,
            "city" : "Denver",
            "availability" : 56,
            "leadTimeInDays" : null,
            "status" : "O",
            "availableToOrder" : false,
            "skuMessage" : null,
            "inStock" : true,
            "directShipped" : false,
            "unitStandard" : null,
            "quantityOnOrder" : null
          },
          "2" : {
            "code" : "Eng",
            "name" : "El Paso, TX",
            "region" : null,
            "city" : "El Paso",
            "availability" : 520,
            "leadTimeInDays" : null,
            "status" : "S",
            "availableToOrder" : false,
            "skuMessage" : null,
            "inStock" : true,
            "directShipped" : false,
            "unitStandard" : null,
            "quantityOnOrder" : null
          },
          "3" : {
            "code" : "EV",
            "name" : "Elizabeth, NJ",
            "region" : null,
            "city" : "Peachtree City",
            "availability" : 345,
            "leadTimeInDays" : null,
            "status" : "O",
            "availableToOrder" : false,
            "skuMessage" : null,
            "inStock" : true,
            "directShipped" : false,
            "unitStandard" : null,
            "quantityOnOrder" : null
          },
          "4" : {
            "code" : "SIL",
            "name" : "Sioux Falls, SD",
            "region" : null,
            "city" : "Sioux Falls",
            "availability" : 6,
            "leadTimeInDays" : null,
            "status" : "O",
            "availableToOrder" : false,
            "skuMessage" : null,
            "inStock" : true,
            "directShipped" : false,
            "unitStandard" : null,
            "quantityOnOrder" : null
          },
          "5" : {
            "code" : "JT",
            "name" : "Jacksonville, FL",
            "region" : null,
            "city" : "Jacksonville",
            "availability" : 624,
            "leadTimeInDays" : null,
            "status" : "S",
            "availableToOrder" : false,
            "skuMessage" : null,
            "inStock" : true,
            "directShipped" : false,
            "unitStandard" : null,
            "quantityOnOrder" : null
          }
        }
      },
      "1" : {
        "code" : "cmmt82329",
        "wholeUnit" : "",
        "wholeUnitPrice" : null,
        "calculatedPrice" : null,
        "unitPrice" : null,
        "altPrice" : null,
        "specialOrder" : false,
        "erpDirectShipped" : false,
        "canPurchase" : true,
        "canPurchaseMessage" : null,
... omitted for brevity
In this article