Skip to content

API Measurements cookbook

This guide explains how to use the public measurements API, how to interpret metric metadata, and how to calculate common customer-facing values from returned rows.

Use the measurements API for new integrations

Section titled “Use the measurements API for new integrations”

Preferred endpoints:

  • GET /api/v1.25f/devices
  • GET /api/v1.25f/metrics
  • GET /api/v1.25f/devices/{device_id}/metrics
  • POST /api/v1.25f/measurements
  • GET /api/v1.25f/queries/{query_id}/status
  • GET /api/v1.25f/queries/{query_id}/result

Legacy endpoints ending in .json are deprecated and should not be used for new work:

  • GET /api/v1.25f/devices/list.json
  • GET /api/v1.25f/devices/consumption.json
  • GET /api/v1.25f/objects/list.json
  1. Discover devices with GET /devices
  2. Discover metric definitions with GET /metrics
  3. Check the metrics that actually exist on one device with GET /devices/{device_id}/metrics
  4. Submit a query with POST /measurements
  5. Poll with GET /queries/{query_id}/status
  6. Read rows with GET /queries/{query_id}/result
  7. Apply the formula that matches the metric family

Current measurements API limits:

  • maximum time range: 5 days
  • maximum devices per query: 5
  • maximum metrics per query: 5
  • minimum time range: none

Short windows such as 5, 15, or 30 minutes are supported. That is useful for onboarding, debugging, and formula validation.

GET /api/v1.25f/devices

Example response:

{
"devices": [
{
"device_id": 210404,
"name": "Main Feed - Building 3",
"device_type": "gridmate",
"is_active": true,
"object_id": 31021,
"object_name": "Riga Plant - Building 3"
},
{
"device_id": 210405,
"name": "Solar Inverter - Roof A",
"device_type": "gridlink",
"is_active": true,
"object_id": 31021,
"object_name": "Riga Plant - Building 3"
}
]
}

GET /api/v1.25f/metrics

Example response:

{
"metrics": [
{
"metric_id": 4007,
"name": "gridmate_total_pos_active_energy_wh",
"unit": "Wh",
"data_type": "COUNTER",
"description": "Gridmate per-phase positive active energy counter.",
"is_phased": true,
"phase_behavior": "phases_1_3_with_legacy_phase_4",
"recommended_phase_handling": "group_by_phases_1_3_ignore_4_by_default",
"aggregation_guidance": [
{
"agg_fn": "SUM",
"description": "Sum energy deltas"
}
]
},
{
"metric_id": 7001,
"name": "gridlink_voltage_histogram",
"unit": "V",
"data_type": "SUMMARY",
"description": "Gridlink voltage distribution histogram.",
"is_phased": true,
"phase_behavior": "phases_1_3_only",
"recommended_phase_handling": "group_by_phases_1_3",
"aggregation_guidance": [
{
"agg_fn": "SUM",
"description": "Merge histograms by summing bucket counts"
}
],
"complex_payload_type": "voltage_histogram"
}
]
}

GET /api/v1.25f/devices/{device_id}/metrics

This is the best starting point for a real query because it tells you which metrics are present on that device, which phases can appear, and how the metric should be interpreted.

Example response:

{
"device_id": 210404,
"metrics": [
{
"metric_id": 4001,
"name": "gridmate_rms_voltage_v",
"unit": "V",
"data_type": "GAUGE",
"available_phases": ["1", "2", "3", "4"],
"is_phased": true,
"phase_behavior": "phases_1_3_with_legacy_phase_4",
"recommended_phase_handling": "group_by_phases_1_3_ignore_4_by_default",
"aggregation_guidance": [
{
"agg_fn": "AVG",
"description": "Time-weighted average RMS voltage"
}
]
},
{
"metric_id": 7001,
"name": "gridlink_voltage_histogram",
"unit": "V",
"data_type": "SUMMARY",
"available_phases": ["1", "2", "3"],
"is_phased": true,
"phase_behavior": "phases_1_3_only",
"recommended_phase_handling": "group_by_phases_1_3",
"aggregation_guidance": [
{
"agg_fn": "SUM",
"description": "Merge histograms by summing bucket counts"
}
],
"complex_payload_type": "voltage_histogram"
}
]
}

Every metric definition now includes interpretation fields that are meant to be used directly by clients.

  • true: the metric normally has per-phase rows
  • false: the metric should be treated as one non-phased series

Current values:

  • non_phased
  • phases_1_3_only
  • phases_1_3_with_legacy_phase_4

Current values:

  • do_not_group_by_phase
  • group_by_phases_1_3
  • group_by_phases_1_3_ignore_4_by_default

If you are building default customer-facing behavior, use recommended_phase_handling instead of inventing your own rule.

This comes from the metric definition source data and tells you which aggregation rule matches the metric family.

Examples:

  • AVG: time-weighted average voltage, current, temperature, or power
  • SUM: energy deltas or merged histograms
  • MAX: peak-style metrics
  • NONE: point-in-time structured payloads such as fuse states

Present only when the metric returns val_complex.

Current values:

  • fuse_state_array
  • voltage_histogram

Example: short counter query using default quality handling

Section titled “Example: short counter query using default quality handling”
{
"type": "timeseries",
"device_ids": [210404],
"metric_ids": [4007],
"time_from": "2026-01-15T10:00:00Z",
"time_to": "2026-01-15T10:15:00Z"
}

Because quality_filter is omitted, this request uses the default quality_filter=ok.

{
"type": "timeseries",
"device_ids": [210404],
"metric_ids": [4001],
"time_from": "2026-01-15T10:00:00Z",
"time_to": "2026-01-15T10:30:00Z",
"phase_filter": 1,
"quality_filter": "ok"
}

If you omit quality_filter, the API uses:

"quality_filter": "ok"

Use this default for business calculations.

Request not-ok only when you are inspecting bad rows.

Request all only when you intentionally want both good and bad rows.

If you omit phase_filter, the API returns:

  • phase 1
  • phase 2
  • phase 3
  • non-phased rows with empty phase ""

If a metric has legacy phase 4, it is excluded by default.

Phase 4 is returned only when you explicitly request:

"phase_filter": 4

Submission returns:

{
"query_id": "0196291a-0931-7d5d-8b7d-4f0d6c0f1a2b"
}

Then poll:

  • GET /api/v1.25f/queries/{query_id}/status
  • GET /api/v1.25f/queries/{query_id}/result

States:

  • preparing
  • running
  • done
  • error
  • none
{
"device_id": 210404,
"metric_id": 4007,
"phase": "1",
"measurement_time": "2026-01-15T10:15:00Z",
"val_rate": 0.0002777778,
"val_counter": 15234.5,
"validity_sec": 900,
"val_complex": null,
"quality_status": "ok",
"quality_flags": []
}
{
"device_id": 210404,
"metric_id": 4001,
"phase": "1",
"measurement_time": "2026-01-15T10:15:00Z",
"val_rate": 229.8,
"val_counter": null,
"validity_sec": 900,
"val_complex": null,
"quality_status": "ok",
"quality_flags": []
}

Field meaning:

  • device_id: device identifier
  • metric_id: metric identifier
  • phase: "", "1", "2", "3", or sometimes legacy "4"
  • measurement_time: interval end timestamp
  • val_rate:
    • gauge value for GAUGE
    • normalized delta per second for COUNTER
  • val_counter: raw cumulative counter value for COUNTER
  • validity_sec: duration covered by the row
  • val_complex: structured payload for supported SUMMARY metrics
  • quality_status: ok or not-ok
  • quality_flags: row-level quality details

Two rules matter most:

  1. Never sum val_counter
  2. For interval totals, use val_rate * validity_sec
  • val_counter is the running total at the end of the interval. If you sum multiple rows, you count the same historical energy again and again.
  • val_rate for COUNTER rows is already normalized to per-second change. Multiplying by validity_sec reconstructs the amount that actually belongs to that interval.
  • The sum covers only the intervals represented by returned rows. Missing or quality-filtered data must not be treated as zero consumption or as complete period coverage.

Example:

  • row at 10:15 with val_counter=15234.5 and val_rate=0.0002777778, validity_sec=900 means the interval contributed 0.25 Wh
  • row at 10:30 with val_counter=15234.8 and val_rate=0.0003333333, validity_sec=900 means the interval contributed 0.30 Wh

Correct total: 0.25 + 0.30 = 0.55 Wh

Incorrect total: 15234.5 + 15234.8 because those numbers are cumulative readings, not interval consumption

Most customer-facing electrical analysis should use:

  • phase 1
  • phase 2
  • phase 3

Non-phased metrics use:

  • empty phase ""

Do not group those rows by phase.

Some Gridlink and Gridmate metrics can expose phase 4 in legacy raw data.

Treat phase 4 as redundant legacy channel data, not as a physical fourth electrical phase.

Safe default:

  • use phases 1, 2, and 3
  • ignore phase 4 unless you explicitly need legacy raw-channel analysis
  • do not sum phase 4 together with phases 1, 2, and 3 in normal customer calculations

Phase 4 is not an extra customer-facing electrical leg. Including it in default totals can duplicate information and overstate results.

Examples:

  • voltage
  • current
  • active power
  • temperature

Use val_rate as the interval value.

A GAUGE row describes the measured level during that interval. There is no cumulative reading to unwrap, so customer calculations should start from the reported gauge value and then apply the metric-specific aggregation rule such as weighted average, max, or energy integration.

Examples:

  • positive active energy
  • negative active energy
  • pulse counters

Use:

  • val_counter as the raw cumulative reading
  • val_rate * validity_sec as the interval delta

val_counter is useful for audit, debugging, and showing the meter reading itself. It is not the interval total. The interval total is the change during the covered time, and the API already exposes that change as normalized val_rate, which must be multiplied back by validity_sec.

Examples:

  • fuse state arrays
  • voltage histograms

Use val_complex.

Check complex_payload_type before decoding.

These metrics are structured payloads, not scalar values. They cannot be interpreted with the counter or gauge formulas.

Metrics with complex_payload_type=fuse_state_array return an array:

[1, 1, 1, 0, 1, 1, 0, 0]

Interpretation:

  • each array entry is one fuse position
  • 1 means closed or on
  • 0 means open or off

These payloads are snapshots. They are not normally aggregated over time.

Why not aggregate them with averages or sums: the payload answers a state question, not an energy or level question. For example, summing two fuse-state arrays does not produce a meaningful electrical measurement.

Metrics with complex_payload_type=voltage_histogram return an object:

{
"min": 220,
"max": 224,
"total_count": 50,
"buckets": [
{ "label": "220-221", "min": 220, "max": 221, "count": 10 },
{ "label": "221-222", "min": 221, "max": 222, "count": 20 },
{ "label": "222-223", "min": 222, "max": 223, "count": 15 },
{ "label": "223-224", "min": 223, "max": 224, "count": 5 }
]
}

Interpretation:

  • min and max describe the covered range
  • total_count is the total sample count
  • each bucket describes a voltage range and sample count

These payloads are for distribution analysis, not for simple counter or gauge formulas.

Why not use gauge or counter formulas: a histogram row is already an aggregated distribution. You merge compatible histograms by summing bucket counts, not by summing val_rate or reading it like a counter.

Use this for COUNTER metrics whose unit is already energy, such as gridmate_total_pos_active_energy_wh.

For gridmate_total_pos_active_energy_wh, energy counter values are stored in Wh. After summing, the total remains in Wh; optionally divide by 1000 to present kWh. Do not divide by 3_600_000: that factor applies only to integration of power in watts over seconds (Ws to kWh), and an energy counter summed in Wh does not need it.

Formula:

consumption = Σ(val_rate * validity_sec)

Worked example for two 15-minute rows:

row_1 = 0.0002777778 * 900 = 0.25 Wh
row_2 = 0.0003333333 * 900 = 0.30 Wh
consumption = 0.25 + 0.30 = 0.55 Wh

Each row contributes only the energy that belongs to its own validity window.

Do not use these shortcuts:

  • do not sum val_counter because that adds cumulative meter readings together
  • do not average val_rate when you need total consumption because an average rate is not an energy total
  • do not assume every row covers the same duration; always use validity_sec

2. Consumption from an active power metric

Section titled “2. Consumption from an active power metric”

Use this for GAUGE metrics in watts, such as gridlink_active_power_w or gridmate_avg_active_power_w.

Formula:

consumption_wh = Σ(val_rate * validity_sec) / 3600
consumption_kwh = Σ(val_rate * validity_sec) / 3_600_000

Worked example for two 15-minute rows:

row_1 = 1200 W * 900 s = 1_080_000 W·s
row_2 = 800 W * 900 s = 720_000 W·s
total_wh = 1_800_000 W·s / 3600 = 500 Wh
total_kwh = 1_800_000 W·s / 3_600_000 = 0.5 kWh

Power is an instantaneous level, so energy comes from integrating power over time. 3_600_000 converts watt-seconds to kilowatt-hours.

Do not use these shortcuts:

  • do not sum watts directly because watts are a rate, not an energy amount
  • do not divide by the number of rows when you need consumption; that gives an average power, not total energy
  • match the divisor to the input and output units: W × seconds / 3600 gives Wh; W × seconds / 3_600_000 gives kWh; kW × seconds / 3600 gives kWh

Use this for voltage, current, temperature, power factor, and average power.

Formula:

weighted_average = Σ(val_rate * validity_sec) / Σ(validity_sec)

Worked example with unequal interval lengths:

row_1 = 229.8 V for 900 s
row_2 = 231.0 V for 300 s
weighted_average = (229.8*900 + 231.0*300) / (900 + 300) = 230.1 V

Longer intervals should influence the result more than shorter ones. A plain arithmetic mean only works when every row has the same validity_sec.

Do not use these shortcuts:

  • do not use AVG(val_rate) unless all rows cover equal durations
  • do not sum gauge values because that produces a number with no customer-facing meaning
  • do not use val_counter because gauge metrics do not represent cumulative readings

Use the maximum val_rate from good rows.

A peak metric asks for the highest observed level in the window, not the average level and not the total over time.

Do not use these shortcuts:

  • do not average rows when you need the peak
  • do not sum rows because totals hide the actual maximum
  • do not include not-ok rows unless your analysis explicitly wants suspect values

Common pattern:

  1. group rows by phase
  2. calculate each phase separately
  3. combine phases only when the metric family says that is valid

For normal customer analysis, default to phases 1, 2, and 3.

Phases are separate electrical channels. Calculating each phase first preserves traceability and avoids mixing missing phases, non-phased rows, or legacy phase 4 into the wrong total.

Do not use these shortcuts:

  • do not collapse all rows into one pool before checking phase semantics
  • do not mix empty phase "" rows into phased calculations
  • do not add legacy phase 4 into normal three-phase totals by default

Pulse sensors report readings in metric 8008 (generic_pulse_count), which is a raw COUNTER value: each stored point is a cumulative count. Never sum val_counter, and apply the multiplier only once. The metric is nonphased, so no per-phase summation is involved. Calculate each device and sensor channel separately, using the multiplier for that sensor.

For each interval, derive the pulse count from the rate values, then convert once, where validity_sec is the number of seconds each rate value is valid:

pulse_count = Σ(val_rate * validity_sec)
consumption = pulse_count * multiplier

The multiplier means target units per pulse. Always take the actual configured value and its unit from the device profile in the AdvanGrid system; do not invent a common multiplier and do not assume all devices share the same one.

Hypothetical example: an interval has 120 pulses and the device profile multiplier is 0.01 m³/pulse. The line 120 * 0.01 = 1.2 m³ gives 1.2 m³. If the multiplier is in liters/pulse, the result is in liters; divide by 1000 for m³.

Metric family guidance for common use cases

Section titled “Metric family guidance for common use cases”

Period import consumption from an energy counter

Section titled “Period import consumption from an energy counter”

Use a COUNTER energy metric such as gridmate_total_pos_active_energy_wh.

{
"type": "timeseries",
"device_ids": [210404],
"metric_ids": [4007],
"time_from": "2026-01-01T00:00:00Z",
"time_to": "2026-01-05T23:59:59Z"
}

Then calculate:

Σ(val_rate * validity_sec)

The metric already represents energy, so each row’s delta is already in energy units after multiplying by the covered seconds. This gives the period’s imported energy directly.

Do not calculate it by summing val_counter or by subtracting only the first and last visible counters unless you fully control gap handling and row filtering. The API already gives you interval-safe deltas.

Use a GAUGE power metric such as gridlink_active_power_w.

{
"type": "timeseries",
"device_ids": [210404],
"metric_ids": [2007],
"time_from": "2026-01-15T00:00:00Z",
"time_to": "2026-01-15T23:59:59Z"
}

Then calculate:

Σ(val_rate * validity_sec) / 3_600_000

Power must be integrated over time to become energy. The division converts watt-seconds to kilowatt-hours.

Do not report Σ(val_rate) as consumption. That is only the sum of sampled power levels and changes when the interval size changes.

Use a phased GAUGE metric such as gridmate_rms_voltage_v.

{
"type": "timeseries",
"device_ids": [210404],
"metric_ids": [4001],
"time_from": "2026-01-15T00:00:00Z",
"time_to": "2026-01-15T23:59:59Z"
}

Calculate the weighted average separately for phases 1, 2, and 3.

Voltage is a level, so the right customer-facing summary is the time-weighted mean per phase. Per-phase calculation keeps one unstable phase from being hidden inside an early combined average.

Do not average all rows together first when you still need per-phase visibility, and do not sum voltage readings.

Use gridlink_fuse_state and decode val_complex as a fuse-state array.

This metric answers which fuse positions were open or closed at each snapshot. It is an inspection workflow, not an energy or average-value workflow.

Do not apply counter deltas, weighted averages, or max calculations to the raw array itself.

Use gridlink_voltage_histogram and decode val_complex as a histogram object.

Voltage quality is about the distribution of observed values across ranges. The bucket counts preserve that distribution.

For combining compatible rows, merge buckets by summing matching bucket counts. Do not treat the histogram like a single scalar gauge or counter.

  • prefer the measurements API over legacy .json endpoints
  • discover IDs before building queries
  • let quality_filter default to ok unless you need bad rows
  • omit phase_filter unless you need one explicit phase
  • treat phase 4 as legacy and ignore it by default
  • never sum val_counter
  • use val_rate * validity_sec for interval totals
  • use weighted averages for gauge metrics
  • use aggregation_guidance and recommended_phase_handling instead of guessing
  • expect val_complex only for supported structured metrics