Use Case

This article describes how to use either chrome or IE, or another API tester application to query the aggregate measurements/values associated with tag(s) in Bazefield.  Prior to this, it is suggested to read

Quick Start: Bazefield API

Quick Start: Tag Manager 

Exercise 1:  Querying API with Chrome and Postman 

Importing Post Man Files


Background

This article reviews how to request aggregate statistics of tags within defined interval windows supplied by the user.  This includes minimums, maximums, time averages, standard deviations, etc. 


Prerequisites

Download the Postman file at the bottom of this article and use it according to the guidelines here:

Importing Post Man Files

 

Requests


The aggregate time series requests can either be generated through explicitly providing an interval window (in milliseconds) as in the first 2 queries in the table below, or through a desired number of points.  For the latter, Bazefield will take the {{from}} and {{to}} of the query and evenly divide the period into the desired number of windows to calculate the aggregates.  

  • Substitute {{domain}} with user's web domain and {{tag1}}, {{tag2}}, etc with requested tags to query.  
  • Substitude {{aggregate}} with desired aggregate formula (see table 2)
  • Substitude {{intervalSec}} with desired interval length in milliseconds (10 min = 600000)
  • Substitude {{numPoints}} with desired number of intervals within range (e.g. 2 evenly splits the query period into 2 equal windows)


Request

DescriptionURL Example
Aggregate Time Series (single tag, interval given)Request to grab time series aggregates of a given tag by an aggregate interval (send in milliseconds)

https://{{domain}}.bazefield.com/Bazefield.Services/api/

measurements/{{tag1}}/aggregates/{{aggregate}}/

from/{{from}}/to/{{to}}/interval/{{intervalSec}}?format=json

Aggregate Time Series (Multiple Tags, interval given)Request to grab time series aggregates of multiple tags by an aggregate interval (send in milliseconds)

https://{{domain}}.bazefield.com/Bazefield.Services/api/

measurements/[{{tag1},{{tag2}}]/aggregates/{{aggregate}}/

from/{{from}}/to/{{to}}/interval/{{intervalSec}}?format=json

Aggregate Time Series (Single Tag, interval calculated)Request to grab time series aggregates of single tag by an aggregate interval which is calculated based on number of points (intervals) requested

https://{{domain}}.bazefield.com/Bazefield.Services/api/

measurements/{{tag1}}/aggregates/ {{aggregate}}/

from/{{from}}/to/{{to}}/points/{{numPoints}}?format=json

Aggregate Time Series (Multiple Tags, interval calculated)Request to grab time series aggregates of multiple tags by an aggregate interval which is calculated based on number of points (intervals) requested

https://{{domain}}.bazefield.com/Bazefield.Services/api/

measurements/[{{tag1}},{{tag2}}]/aggregates/{{aggregate}}/

from/{{from}}/to/{{to}}/points/{{numPoints}}?format=json


Accepted Aggregate Inputs


Aggregate

Description

Total

Integrated value of tag in interval (e.g. TagTotal(ActivePower) = Production)

Average

Geometric average of all values in interval

TimeAverage

Time-weighted average of all values in interval

Count

Count of number of values in interval

Stdev

Standard deviation of values in interval

MinimumActualTime

Minimum value within interval

Minimum

Minimum value within interval

MaximumActualTime

Maximum value within interval

Maximum

Maximum value within interval

Start

First value within interval

End

Last value within interval

Delta

Last Value – First Value within interval

Variance

Variance of values within interval

Range

Maximum – Minimum value within interval




Postman queries

The tabular queries above can be modified and used within Postman directly by navigating to the correct request on the left hand collection tab.  




The {{aggregate}}, {{numPoints}}, and {{intervalSec}} arguments for the queries can be edited through the steps below: