Skip to content
We're currently creating a lot of content. Sign up to get notified when it's ready.

Readings

The Reading API lets you get readings data from the network. You can read data from any Asset object in the network using its readings property.

Return value

These values of type AssetReadings are automatically refreshed every few minutes and contain the readings for the current network time sampled with a 15 minute resolution.

readings: AssetReadings & { latest, forRange }

Examples

const sdk = window.qatium
const network = sdk.network
const asset = network.getAsset('Nellybay')
console.log(asset.readings)
// {
// level: {
// date: Date;
// value: number
// }
// }

Query methods

forPeriod()

Returns the cached readings in the current 24 hour period.

Method signature

forPeriod(): AssetReadingsCollection

Parameters

None.

Returns

Return type is AssetReadingsCollection. An array with the readings cached in the 24 hour period, sampled with a 15 minute resolution.

latest()

Retrieves the latest reading for an asset.

Method signature

latest(): Promise<AssetReadings>
Parameters

None.

Returns

A promise that will resolve when the latest available readings are available in an AssetReadings object.

Examples

const sdk = window.qatium
const network = sdk.network
const asset = network.getAsset('Nellybay')
asset.readings.latest().then((reading) => {
console.log(reading)
})

forRange()

Retrieves readings for an asset between two dates.

Method signature

forRange(start: Date, end: Date): Promise<AssetReadings>
Parameters
  • start: Start date
  • end: End date
Returns

A promise that will resolve when the readings are available in an AssetReadings object.

Examples

Get readings for 24 hours for an asset.

const sdk = window.qatium
const network = sdk.network
const asset = network.getAsset('Nellybay')
asset.readings.forRange(new Date("2024-01-01"), new Date("2024-01-02")).then((readings) => {
readings.level.forEach((reading) => {
console.log(reading)
})
})