Skip to content

Prices API Reference

createPriceClient(options)

Creates a new PriceClient instance.

ts
import { createPriceClient } from '@hantera/storefront-sdk/prices'

const prices = createPriceClient({
  baseUrl: 'https://core.your-instance.hantera.cloud',
})

Options

PropertyTypeRequiredDescription
baseUrlstringYesBase URL of the Hantera instance

Methods

lookup(request)

Performs a bulk price lookup for multiple products across specified price lists.

ts
const result = await prices.lookup({
  productNumbers: ['PROD-001', 'PROD-002'],
  priceListKeys: ['RETAIL', 'VIP'],
  currencyCode: 'SEK',
})

Parameters:

FieldTypeDescription
productNumbersstring[]Product identifiers to look up
priceListKeysstring[]Price list keys to search within
currencyCodestringISO currency code (e.g. SEK, EUR)

Returns: Promise<PriceLookupResponse | PriceErrorResponse>


Types

PriceLookupRequest

ts
interface PriceLookupRequest {
  productNumbers: string[]
  priceListKeys: string[]
  currencyCode: string
}

PriceLookupResponse

ts
interface PriceLookupResponse {
  currencyCode: string
  prices: ProductPrice[]
}

ProductPrice

ts
interface ProductPrice {
  productNumber: string
  currentPrice: number | null
  lowestPrice: number | null
  priceTimeline: TimelineEntry[] | null
}
FieldTypeDescription
productNumberstringThe product identifier
currentPricenumber | nullCurrent effective best price, or null if not found
lowestPricenumber | nullLowest price in the 30-day window
priceTimelineTimelineEntry[] | nullChronological price change history

TimelineEntry

ts
interface TimelineEntry {
  price: number
  at: string
}
FieldTypeDescription
pricenumberThe effective best price at this moment
atstringISO 8601 timestamp of the price change

PriceErrorResponse

ts
interface PriceErrorResponse {
  error: {
    code: string
    message: string
  }
}

isPriceError(response)

Type guard to check if a response is a PriceErrorResponse.

ts
import { isPriceError } from '@hantera/storefront-sdk/prices'

const result = await prices.lookup(request)
if (isPriceError(result)) {
  // result is PriceErrorResponse
}