GridBase
    Console

    Search the API reference

    Find an endpoint by name or path

    Sensors

    Sensors and their readings: latest values, history, statistics and health.

    List Sensors

    GET/api/v2/sensors

    Find sensors.

    Query parameters

    • limitrequirede.g. 25

      default 100, max 1000. Refused above, never clamped.

    • qoptionale.g. real-time lmp

      full-text search over sensor, node and network names. Ranks by relevance, and `relevance` appears on each item.

    • tagoptionale.g. sig

      a tag name the sensor must carry.

    • tag_valueoptionale.g. v1:miso:

      a prefix the tag's value must start with. Requires `tag`.

    • network_idoptionale.g. cbace340-e890-441f-b2ce-813706bbddf4

      restrict to one market.

    • node_idoptionale.g. 1fae9137-80bc-43cf-b39b-780808bdebe2

      restrict to one node.

    • statusoptionale.g. active

      pending, active, inactive, archived, or `all`. Default excludes archived — 55 of 172,691 sensors are archived and a caller listing sensors does not mean them.

    • sortoptionale.g. name

      name (default), id, status, unit, created_at, updated_at, node_id, sensor_type_id, or relevance. `relevance` is the default when `q` is set, and a 400 without it — with no query every sensor ranks equally.

    • diroptionale.g. asc

      asc or desc.

    • offsetoptionale.g. 0

      default 0.

    One collection, one item type, and the four ways of narrowing it are query parameters rather than separate routes.

    role. Sensors are catalogue metadata and carry no personal data. Every filter reaches Postgres as a bound parameter — including tag_value, whose LIKE prefix is built in SQL as $6 || '%', so a value containing a wildcard narrows the match rather than widening it and cannot reach the statement text.

    Worth knowing

    Four routes answered in four shapes. /sensors returns {_meta, count, items} with id/name/node_id; /sensors/search returns a bare JSON array with sensor_id/sensor_name/node_name/ network_name and a rank; /sensors/search/tag returns {_meta, count, items} again; /sensors/count returns {count}. Same entity, two field vocabularies, and a client that parses one cannot parse the next.

    Search could not be paged. SearchSensors orders by ts_rank alone, and full-text ranking ties in quantity — the two top hits for real-time lmp both rank exactly 1.0. Two tied rows may swap between page 1 and page 2, repeating one and dropping another, and /sensors/search returns no total so a caller cannot tell how far to page. Every ordering here ends in the primary key, which makes it total, and meta.total is counted under the same predicate as the page.

    Search substituted defaults for anything it could not parse. ?limit=abc and ?limit=-5 both became 50 and returned a well-formed 200. Here:

    ?limit=abc    400 invalid_param   "limit must be an integer"
    ?limit=-5     400 invalid_param   "limit must be at least 1"
    ?limit=9999   400 limit_exceeded  detail {max: 1000, requested: 9999}
    ?status=x     400 invalid_param   detail.allowed lists the five values

    On /api/sensors the same ?limit=-5 is a 500 — DefaultQueryInt32 checks only the upper bound, so the negative reaches Postgres as LIMIT -5. Filed as #161.

    sig: was a magic prefix inside a value. ?q=sig:abc switched /sensors/search to an entirely different query against the sig tag. A mode switch hidden in user input is undiscoverable and a parsing hazard; it is ?tag=sig&tag_value=abc here, which generalises to every tag.

    /sensors/search/tag was named for one tag. It defaulted tagName to sig and required a parameter literally called sig, so searching by urn meant sending ?tagName=urn&sig=<the urn>.

    An empty tag page now says why. tag is polymorphic — target_id names a sensor or a node and nothing in the row says which — and nine of the twelve most-used tag names are attached only to nodes:

    tag name     rows      on sensors
    urn          203,144   152,852
    staleAfter   145,570   145,502
    sig          139,960   139,960
    zone          20,031         0
    pnode_id      17,541         0
    coord_source  16,858         0

    So a tag filter naming a node tag would otherwise return {"count":0,"items":[]} with nothing saying the tag was never a sensor tag. Here that request raises "tag zone exists but is attached to nodes, not sensors, so no sensor can carry it; filter by node_id instead". One extra read, only on an empty page.

    Items carry their node and network. Returning node_id with no name makes rendering a list of sensors cost a request per distinct node; these are two joins, against tables of 51,811 and 13 rows.

    The search index does not cover everything. sensor_search holds 172,675 rows against sensor's 172,691, so sixteen sensors cannot be found by ?q= at all. Because q is a filter here rather than its own endpoint, the same request without it returns them; an empty ?q= page says so in a warning.

    Default limit 100, cap 1000, over 172,691 sensors — a caller that wants more asks for it.

    meta.total on a bare request is 172,636, so there is no separate count route to call.

    unfiltered cost is the exact count(*) over the join; meta.total is worth it on a collection a caller has to page.

    on the ingest cadence.

    Errors

    400invalid_paramlimit/offset not a positive integer; status not one of the five; network_id/node_id not a UUID; sort unknown; sort=relevance without q
    400limit_exceededlimit above 1000
    400missing_paramtag_value without tag
    Security
    a read. Needs a token whose capability covers v2 and `read`; no
    Cost
    0.15s filtered by network, 0.58s unfiltered, 0.95s with `?q=`. The
    Cache
    slow tier. The sensor table changes when a feed is provisioned, not
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors?limit=25" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "sensor",
        "class": "reference",
        "count": 1,
        "limit": 1,
        "offset": 0,
        "total": 172636,
        "sort": "relevance",
        "dir": "desc"
      },
      "items": [
        {
          "id": "00000a49-28ff-481b-a787-5ab8ad7da500",
          "name": "Real-Time LMP",
          "unit": "$/MW",
          "description": "Real-Time LMP Price",
          "status": "active",
          "ttl_days": 1825,
          "anomaly_detection": false,
          "type": {
            "id": "e5c8ad0a-da0d-41a5-8d1d-cb907026101c",
            "code": "rtlmp",
            "name": "Real-Time Locational Marginal Price (LMP)",
            "is_number": true
          },
          "node": {
            "id": "1fae9137-80bc-43cf-b39b-780808bdebe2",
            "name": "lepa",
            "tz": "America/Chicago"
          },
          "network": {
            "id": "57d5dc85-402b-4d17-9385-547036019b85",
            "name": "spp"
          },
          "created_at": "2026-03-29T11:22:39.284185Z",
          "updated_at": "2026-07-15T21:00:17.653504Z",
          "relevance": 1
        }
      ]
    }
    Try it in the Explorer

    Get Sensor

    GET/api/v2/sensors/{sensor_id}

    One sensor, with the node it sits on, the market that node belongs to, and its type.

    Path parameters

    • sensor_idrequirede.g. 00000a49-28ff-481b-a787-5ab8ad7da500

    role. A malformed id is 400 invalid_param naming the field; an unknown one is 404 not_found quoting the id back. Nothing about the failure distinguishes a sensor that exists and is not visible from one that does not exist, because every sensor is visible to every token today — if that ever stops being true, this is the route that has to change first.

    Worth knowing

    The detail view returned fewer fields than the list. /sensors includes anomaly_detection and /sensors/{id} omits it, so fetching one sensor lost a field that listing it gave you. Both routes here read one shared projection, and a test asserts it.

    Three routes collapse into nested objects. /node and /type are one request each for data this response nests, and /custody returns name, unit, node id, node name, network id and network name — a strict subset of what /sensors/{id} already returned, which makes it a route for a projection.

    /type answered 404 "sensor type found" — a message with the "not" missing — where /sensors/{id} answered 404 "sensor not found" for the same condition. One message here, quoting the id.

    node carries tz. Every reading route needs the node's timezone to render a local timestamp, so it travels with the sensor rather than costing a second request.

    Deliberately not nested here: the full node row (lat, lon, node_type_id, created_at, updated_at) and the full network row. A node is its own resource; this carries the identity needed to render a sensor, and /api/v2/nodes/{id} is where the rest will live. Say so if you depend on a field that moved.

    Errors

    400invalid_paramsensor_id is not a UUID
    404not_foundno sensor with that id
    Security
    a read. Needs a token whose capability covers v2 and `read`; no
    Cost
    0.09s — three primary-key joins.
    Cache
    slow tier. A sensor row changes when a feed is reconfigured.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/00000a49-28ff-481b-a787-5ab8ad7da500" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "sensor",
        "class": "reference",
        "as_of": "2026-07-15T21:00:17.653504Z"
      },
      "item": {
        "id": "00000a49-28ff-481b-a787-5ab8ad7da500",
        "name": "Real-Time LMP",
        "unit": "$/MW",
        "description": "Real-Time LMP Price",
        "status": "active",
        "ttl_days": 1825,
        "anomaly_detection": false,
        "type": {
          "id": "e5c8ad0a-da0d-41a5-8d1d-cb907026101c",
          "code": "rtlmp",
          "name": "Real-Time Locational Marginal Price (LMP)",
          "is_number": true
        },
        "node": {
          "id": "1fae9137-80bc-43cf-b39b-780808bdebe2",
          "name": "lepa",
          "tz": "America/Chicago"
        },
        "network": {
          "id": "57d5dc85-402b-4d17-9385-547036019b85",
          "name": "spp"
        },
        "created_at": "2026-03-29T11:22:39.284185Z",
        "updated_at": "2026-07-15T21:00:17.653504Z"
      }
    }
    Try it in the Explorer

    Update Sensor

    PATCH/api/v2/sensors/{sensor_id}

    Change a sensor's editable fields.

    Path parameters

    • sensor_idrequirede.g. 00000a49-28ff-481b-a787-5ab8ad7da500

    SECURITY — THIS IS THE FIRST WRITE IN THE SENSORS DOMAIN. The v2 group gate (v2mw.Capability()) requires BOTH:

    • a token whose auth_token_capability row grants v2 and write, and
    • the contributor role on the user.

    They intersect; neither widens the other. The token says what the credential may do, the role says what the user may do. Capability is cached per process for 60 seconds; the role is NOT cached, because a cached role meant a revoked contributor kept writing for a minute.

    A read-only token gets, before this handler runs at all:

    // 403
    {
        "code": "forbidden",
        "message": "this token is read-only",
        "request_id": "...",
        "detail": { "required_access": "write", "token_access": "read" }
      }

    Do not add auth.RequireRole to this route — the group gate already asks.

    Editable: name, unit, description, status, ttl_days, anomaly_detection.

    NOT editable, deliberately: node_id and sensor_type_id. Accepting them lets one request move a sensor to another node, into another market, and change what its readings mean — with a hypertable of readings already attached to it and no migration of those rows. Re-pointing a sensor is a different operation from editing it and does not belong behind the same verb.

    Request: send only the fields you want to change. { "name": "Real-Time LMP", "unit": "$/MW", "description": "Real-Time LMP Price", "status": "active", "ttl_days": 1825, "anomaly_detection": false }

    Response: the full sensor, in the same shape Get Sensor returns.

    Worth knowing

    It is a PATCH, and it behaves like one: the fields you omit are preserved. Under PUT, a caller sending a partial body would reasonably expect the omitted fields to be cleared.

    Only the columns you sent are written. Loading the row, merging the body into it and writing all eight columns back puts a read and a write outside a transaction, so two concurrent edits to different fields lose one of them. The SET clause is built from the fields the body carried and applied as a single UPDATE … RETURNING, so there is no read-then-write window and no second query to fetch what was written.

    ttl_days: null clears the retention limit. absent and null are distinguishable, which is what Optional[T] exists for — treating them identically means a TTL can be set and never cleared.

    Validation names its field. Every refusal carries field and, for an enum, detail.allowed, rather than putting the allowed values in prose:

    {}                          400 invalid_param, detail.updatable lists the six
    {"name": ""}                400 invalid_param, field "name"
    {"name": null}              400 invalid_param, field "name"
    {"status": "bogus"}         400 invalid_param, field "status", detail.allowed
    {"ttl_days": 0}             400 invalid_param, field "ttl_days"
    {"anomaly_detection": null} 400 invalid_param, field "anomaly_detection"

    An empty body is refused rather than answering 200 having written nothing, which hides a client bug.

    anomaly_detection is editable. It is the one flag that decides whether a sensor gets a baseline computed (#165), so leaving it out of the update struct makes it unsettable through the API at all.

    Column names in the SET clause come from this handler and only values are bound, asserted in a test.

    Errors

    400invalid_paramsensor_id not a UUID; unparseable body; empty body; a field whose value is not acceptable
    403forbiddentoken is read-only, or the user lacks the contributor role
    404not_foundno sensor with that id
    Cache
    never stored. Writes run under v2mw.NoStore().
    curl -X PATCH "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/00000a49-28ff-481b-a787-5ab8ad7da500" \
      -H "Authorization: $GRIDBASE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "description": "Real-Time LMP Price"
    }'

    Baseline

    GET/api/v2/sensors/{sensor_id}/baseline

    The hour-of-week baseline an anomaly detector compares a reading against.

    Path parameters

    • sensor_idrequirede.g. 00000a49-28ff-481b-a787-5ab8ad7da500

    THIS ENDPOINT RETURNS NO DATA ON PRODUCTION TODAY. sensor_baseline_hwh holds zero rows across the whole fleet — the background task that populates it has either never run, never been deployed, or is failing silently. Note that sensor.anomaly_detection is a precondition for the task and is false on the sensors sampled, so an empty table may be correct behaviour for a feature nobody has enabled. Establishing which is what #165 tracks.

    The route is ported because the table, the columns and the task all exist and the shape is settled. It will start returning figures the moment the task does.

    Worth knowing

    "Not computed yet" is distinguishable from "no such sensor". Answering 404 to both leaves a client unable to tell a typo from a feature that has not run yet. An uncomputed baseline is a 200 with computed: false, every figure an explicit null, and a warning; 404 means the sensor is not there.

    warmed_up is reported separately from computed. A baseline can exist and have too few samples to rely on, so a cold one raises a warning rather than sitting as one field among thirteen.

    Field names say what the figures are: hour_of_week_avg, hour_of_week_p95, samples_90d. The columns are hwh_avg, hwh_p95 and sample_count_90d, and hwh is not a word a client can be expected to expand.

    sensor_id is gone from the body — it is in the path.

    Errors

    400invalid_paramsensor_id is not a UUID
    404not_foundno sensor with that id
    Security
    a read behind the v2 capability gate (`v2` + `read`, no role).
    Cost
    0.16s, one primary-key lookup.
    Cache
    slow tier.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/00000a49-28ff-481b-a787-5ab8ad7da500/baseline" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "sensor_baseline_hwh",
        "class": "computed",
        "warnings": ["no baseline has been computed for this sensor. The sensor_baseline_hwh table is populated by a background task and is empty across the fleet today (#165); every figure is null"]
      },
      "item": {
        "computed": false,
        "warmed_up": false,
        "computed_at": null,
        "hour_of_week_avg": null,
        "hour_of_week_stddev": null,
        "hour_of_week_p95": null,
        "hour_of_week_p99": null,
        "hour_of_week_p01": null,
        "hour_of_week_samples": null,
        "avg_90d": null,
        "stddev_90d": null,
        "p99_90d": null,
        "p01_90d": null,
        "samples_90d": null
      }
    }
    Try it in the Explorer

    Current

    GET/api/v2/sensors/{sensor_id}/current

    Where a sensor stands right now: the reading before this instant and the reading after it.

    Path parameters

    • sensor_idrequirede.g. a69c4adc-d131-412a-8192-402ef3b468dc

    at is the instant the two readings are measured against. seconds is the distance from it — how old previous is, how far ahead next is — always non-negative, with the direction given by the field it sits under.

    meta.class is forecast when the sensor publishes ahead of now and measured when it does not.

    Why this replaces three routes.

    "Latest" must not mean "furthest in the future". There are three windows over one series: the last row at or before now, the first row after it, and the row with the highest ts within fourteen days either side — and the third, on a forecast sensor, is the furthest-ahead forecast, not the most recent reading. Measured on PJM's Forecasted Load (a69c4adc) at 2026-11-07T14:09Z:

    /cur     2026-11-07T09:05:00-05:00    82,751 MW   five minutes ago
    /next    2026-11-07T09:10:00-05:00    82,763 MW
    /latest  2026-11-13T23:00:00-05:00    90,494 MW   six days ahead

    A client reading /latest for "the current value" gets next Friday's peak, about 8,000 MW off, with nothing in the response saying the timestamp is ahead of now. On a sensor with no future rows all three agree — which is why the trap survives: it only bites on the forecast sensors where the number matters most. Here both sides are named, so no field can be mistaken for the other.

    Three requests become one. An instrument panel reading cur, next and latest spends three round trips on one sensor. Both halves run as a single statement: two bounded LIMIT 1 scans in one CTE.

    A silent sensor is not a 404. The scan is bounded to ±14 days — deliberately, so TimescaleDB prunes ~1,690 of ~1,696 chunks instead of walking them — but a sensor whose last reading is older than that is a different fact from an id that does not exist, and gets a different answer. "This sensor is stale", "this sensor never reported" and "there is no such sensor" are one response, and only the last is the caller's to fix. Here a stale sensor is a 200:

    {
      "meta": {
        "source": "sensor_num_series_v2",
        "class": "measured",
        "warnings": [
          "this sensor has no reading within 14 days either side of now; it exists but is not reporting. Use /readings with an explicit from/to to look further back"
        ]
      },
      "item": { "at": "2026-11-07T14:15:39Z", "previous": null, "next": null }
    }

    and 404 is reserved for a sensor that is not there. A forecast sensor with no recent actuals — previous null, next set — gets its own warning.

    previous and next are explicit nulls, not omitted. Either may legitimately be absent, and omitempty would make "this sensor has no forecast" indistinguishable from "this endpoint does not return one".

    now() is compared to the column directly. ts is timestamp with time zone, so NOW() AT TIME ZONE 'UTC' would strip the zone to a timestamp that Postgres then reinterprets using the session timezone — correct only while the pool happens to run Etc/UTC, which is a latent dependency on a setting the query does not state.

    Timestamps are UTC, as everywhere here. /sensors/{id} carries node.tz for a client that wants to render local.

    For a batch across many sensors, see Latest (batch), which reads the trigger-maintained sensor_num_series_latest table instead.

    Errors

    400invalid_paramsensor_id is not a UUID
    404not_foundno sensor with that id
    Security
    a read behind the v2 capability gate (`v2` + `read`, no role).
    Cost
    0.1s — two bounded single-row index scans.
    Cache
    live tier, 60s.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/a69c4adc-d131-412a-8192-402ef3b468dc/current" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "sensor_num_series_v2",
        "class": "forecast",
        "as_of": "2026-11-07T14:15:00Z"
      },
      "item": {
        "at": "2026-11-07T14:15:24.984355Z",
        "previous": { "ts": "2026-11-07T14:15:00Z", "val": 82709, "seconds": 24 },
        "next":     { "ts": "2026-11-07T14:20:00Z", "val": 82707, "seconds": 275 }
      }
    }
    Try it in the Explorer

    Sensor Health

    GET/api/v2/sensors/{sensor_id}/health

    Whether one sensor is reporting.

    Path parameters

    • sensor_idrequirede.g. 00000a49-28ff-481b-a787-5ab8ad7da500

    Worth knowing

    THE TWO ROUTES DISAGREED ABOUT THE ROW COUNT, 4.4x APART. /health reads sensor_num_series_health, whose row_count comes from sensor_num_series_count — a materialized view — while /status runs a live COUNT(n.ts) over the hypertable. On this sensor, 2026-11-07:

    /health   rowCount          14,291
    /status   num_series_count  63,263
    live count                  63,263

    Neither response says which figure it is or how stale the cached one is. Here the field is readings_counted and meta.notes states its source. Filed as #164.

    /status scanned the whole hypertable to answer a metadata question. It LEFT JOINs sensor_num_series_v2 and sensor_text_series with no time predicate and groups — 0.65s against 0.15s for /health. The two joins also multiply: a sensor with both numeric and text series would report num_series_count times the text row count. sensor_text_series is empty today, so that is wrong by construction rather than in practice. The metadata /status also returned (id, name, unit, sensor_type_id, created_at, updated_at, ttl_days) is on /sensors/{id}, and the series bounds it reported are on /summary as first and last.

    age was a Go duration string. "1m4.046475347s" is time.Duration.String(), which no JSON client parses without a Go-specific routine — beside a staleAfter of "30m" that also has to be parsed before the two can be compared. Both are integer seconds here.

    One naming convention, so this route and the fleet one read the same. {health, ok, staleAfter, age, rowCount} against {status, row_count, stale_after} on the fleet route. ok is just status == "healthy" and invites a client to branch on both. One convention, one name, no redundant boolean.

    status: unknown is explained. It means the sensor carries no staleAfter tag or has never reported — the absence of a judgement, not a healthy one. A warning says so, because a client treating it as healthy misses exactly the sensors nobody is watching.

    Errors

    400invalid_paramsensor_id is not a UUID
    404not_foundno sensor with that id
    Security
    a read behind the v2 capability gate (`v2` + `read`, no role).
    Cost
    0.1s.
    Cache
    slow tier.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/00000a49-28ff-481b-a787-5ab8ad7da500/health" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "sensor_num_series_health",
        "class": "computed",
        "as_of": "2026-11-07T15:00:00Z",
        "notes": ["readings_counted comes from sensor_num_series_count, a materialized view refreshed on a schedule, so it lags the live table. For an exact count over a window use /sensors/{id}/summary."]
      },
      "item": {
        "sensor_id": "00000a49-28ff-481b-a787-5ab8ad7da500",
        "sensor_name": "Real-Time LMP",
        "status": "healthy",
        "last_reading_at": "2026-11-07T15:00:00Z",
        "age_seconds": 59,
        "last_value": 22.3425,
        "stale_after_seconds": 1800,
        "readings_counted": 14291
      }
    }
    Try it in the Explorer

    Peaks

    GET/api/v2/sensors/{sensor_id}/peaks

    The highest readings a sensor recorded in a window.

    Path parameters

    • sensor_idrequirede.g. 00000a49-28ff-481b-a787-5ab8ad7da500

    Query parameters

    • limitrequirede.g. 10

      default 10, max 99.

    • rollupoptionale.g. hour

      none (default) returns the top readings; hour returns the top local hours by their highest reading.

    • fromoptionale.g. 2026-11-06
    • tooptionale.g. 2026-11-07

    With rollup=hour, meta.notes names the zone the hours were cut in.

    rollup is checked against an allow-list and then selects between two fixed statements; the timezone is a bound parameter, never interpolated into the bucket expression.

    Worth knowing

    Hourly buckets are cut in the node's own timezone. Grouping on date_trunc('hour', ts) where ts is a timestamptz truncates in the session timezone — UTC in production — which then disagrees with rendering each bucket in the node's local zone. The two agree only for markets whose offset is a whole number of hours. That is every market today and is not a property anything enforces, so an hour labelled local was cut in UTC. Here the truncation happens in the node's zone and meta.notes names it. Same defect family as the power-grid seasonal thresholds route.

    ?limit= reaches the range it advertises. Clamping to a default of 10 before checking a declared range of 1–99 makes the advertised range unreachable — ?limit=11 then returns:

    {"error":"cannot exceed 10"}{"count":10,"items":[...]}

    two JSON documents in one response body, because the helper writes its 400 and the handler carries on. Here 1–99 all work and 100 is a clean 400 invalid_param carrying detail.min and detail.max.

    Rows carry their rank, rather than leaving a caller to infer position from array order — which breaks the moment anything re-sorts it.

    The ordering is total: ties break on timestamp, so the Nth and N+1th cannot swap between requests.

    Timestamps are UTC, as everywhere here.

    Errors

    400invalid_paramsensor_id not a UUID; unparseable from/to; limit outside 1-99; rollup not none/hour
    400window_too_largespan longer than 31 days
    404not_foundno sensor with that id
    Security
    a read behind the v2 capability gate (`v2` + `read`, no role).
    Cost
    0.15s.
    Cache
    slow tier.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/00000a49-28ff-481b-a787-5ab8ad7da500/peaks?limit=10" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "sensor_num_series_v2",
        "class": "computed",
        "as_of": "2026-11-06T22:50:00Z",
        "coverage": { "from": "2026-11-06T14:54:42Z", "to": "2026-11-07T14:54:42Z" },
        "count": 3, "limit": 3, "sort": "val", "dir": "desc"
      },
      "items": [
        { "ts": "2026-11-06T22:50:00Z", "val": 68.855,  "rank": 1 },
        { "ts": "2026-11-06T22:55:00Z", "val": 52.8817, "rank": 2 },
        { "ts": "2026-11-06T22:45:00Z", "val": 49.91,   "rank": 3 }
      ]
    }
    Try it in the Explorer

    Ranges

    GET/api/v2/sensors/{sensor_id}/ranges

    The display bands configured for a sensor — the colour scale a gauge or chart is drawn against.

    Path parameters

    • sensor_idrequirede.g. 00000a49-28ff-481b-a787-5ab8ad7da500

    Worth knowing

    It is a collection in the standard envelope, not a bare array, so a generic client unwraps items here as it does everywhere else.

    from and to, not start_range and end_range, per the naming rule, and both nullable: an open-ended top or bottom band is a real configuration. The sentinel values in the data today (-9999 and 9999) are not measurements and a client should not render them as axis bounds.

    sensor_id is not repeated on each row — it is in the path.

    An empty set says so, and points at /summary for a scale to fall back on.

    Ordering is total: start_range then id, so two bands sharing a lower bound have a stable order.

    the fleet.

    Errors

    400invalid_paramsensor_id is not a UUID
    404not_foundno sensor with that id
    Security
    a read behind the v2 capability gate (`v2` + `read`, no role).
    Cost
    0.05s, one indexed read. The table is 91 MB over 467,307 rows across
    Cache
    static tier — bands change when someone reconfigures a sensor.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/00000a49-28ff-481b-a787-5ab8ad7da500/ranges" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": { "source": "sensor_num_range", "class": "reference",
                "count": 6, "sort": "from", "dir": "asc" },
      "items": [
        { "id": "b08680fa-…", "name": "Very Low",  "from": -9999, "to": 10.99,  "color": "#008000" },
        { "id": "430012f0-…", "name": "Low",       "from": 11,    "to": 21.99,  "color": "#32CD32" },
        { "id": "2ffd0eb1-…", "name": "Normal",    "from": 22,    "to": 79.99,  "color": "#0000FF" }
      ]
    }
    Try it in the Explorer

    Readings

    GET/api/v2/sensors/{sensor_id}/readings

    A sensor's series over a window.

    Path parameters

    • sensor_idrequirede.g. 00000a49-28ff-481b-a787-5ab8ad7da500

    Query parameters

    • limitrequirede.g. 100

      default 1000, max 10000. Refused above, never clamped.

    • fromoptionale.g. 2026-11-06
    • tooptionale.g. 2026-11-07
    • diroptionale.g. asc

      asc (default) or desc.

    • offsetoptionale.g. 0

      default 0.

    The sensor id is a path UUID and the window goes through respond.ParseWindow; every value reaches Postgres as a bound parameter. Readings are market telemetry and carry no personal data.

    Worth knowing

    meta.class says whether you are looking at measurements or forecast. A page whose timestamps reach past now contains forecast rows, and without the class a client charting a forecast sensor cannot tell where the actuals stop.

    meta.coverage is the span actually served, not the span requested. A 24-hour window that returns an hour of readings says so, and a full page raises a warning rather than silently appearing to end early.

    The window is half-open: ts >= from AND ts < to, matching respond.Window and every other route here. Inclusive at both ends, two adjacent windows both contain the boundary reading and a caller stitching them together counts it twice.

    Timestamps are UTC. Converting each ts to the node's zone preserves the instant, but a page spanning markets then carries four different offsets and a caller comparing two series has to normalise first. /sensors/{id} carries node.tz for rendering local.

    from/to, not start/end, and parsed the same way on every route — so the bare date 2026-11-01 means one instant whichever route you send it to.

    The span is capped: over 31 days is 400 window_too_large carrying detail.max_days and detail.requested_seconds. Uncapped, a year-wide request walks a year of chunks to return one page.

    An unknown sensor is distinguishable from a silent one. A single 404 "no data found" covering a stale sensor, a sensor that never reported and an id that does not exist tells a caller none of the three. An unknown id is 404 "no sensor with id ..." and a silent sensor is a 200 with an empty items and a warning naming the window it searched.

    A null val is reported as null and counted. The column is nullable: a row can exist for a timestamp with no measurement, which is a different fact from a gap in the series, and a caller averaging the page needs to know how many it is skipping.

    The ordering is total. (sensor_id, ts) carries no unique constraint, so ordering by ts alone could let two rows sharing a timestamp swap between pages; val is appended as a tiebreak.

    /api/sensors/data is not replaced one-for-one. It addresses a series by network, node and sensorId — which holds a sensor name, not an id — and joins on s.name = $2. (node_id, name) is unique across all 172,691 sensors today, but nothing constrains it, so the query is one duplicate insert away from silently merging two series. In v2 that is two calls:

    GET /api/v2/sensors?network_id=<id>&node_id=<id>&q=Real-Time%20LMP
    GET /api/v2/sensors/<id from above>/readings

    Errors

    400invalid_paramsensor_id not a UUID; unparseable from/to; dir not asc/desc; limit or offset not a positive integer
    400window_too_largespan longer than 31 days
    400limit_exceededlimit above 10000
    404not_foundno sensor with that id
    Security
    a read behind the v2 capability gate (`v2` + `read`, no role).
    Cost
    0.1-0.3s for a day of 5-minute data.
    Cache
    live tier, 60s — the series moves with the ingest cadence.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/00000a49-28ff-481b-a787-5ab8ad7da500/readings?limit=100" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "sensor_num_series_v2",
        "class": "measured",
        "as_of": "2026-11-06T14:25:00Z",
        "coverage": { "from": "2026-11-06T14:20:00Z", "to": "2026-11-06T14:25:00Z" },
        "count": 2,
        "limit": 2,
        "offset": 0,
        "total": 287,
        "sort": "ts",
        "dir": "asc",
        "warnings": [
          "this page is full, so the window continues past the last reading; page with offset or narrow from/to"
        ]
      },
      "items": [
        { "ts": "2026-11-06T14:20:00Z", "val": 27.1565 },
        { "ts": "2026-11-06T14:25:00Z", "val": 25.2669 }
      ]
    }
    Try it in the Explorer

    Series Extent

    GET/api/v2/sensors/{sensor_id}/series

    How far back a sensor's data goes, and how much of it there is — all time, no window.

    Path parameters

    • sensor_idrequirede.g. 00000a49-28ff-481b-a787-5ab8ad7da500

    The all-time extent of a sensor's series: first and last reading, and the all-time minimum and maximum. /summary's min and max are windowed; these are not.

    This exists because every other v2 aggregate is windowed. /summary caps its window at 31 days, so without this route "how far back can I chart this sensor" would have no answer at all.

    The metadata half of /status (id, name, unit, sensor_type_id, created_at, updated_at, ttl_days) is on /sensors/{id}.

    count is exact. /sensors/{id}/health's readings_counted is the cached figure from a materialized view and reads 77% low today (#164); this is the live count.

    span_days is last_at - first_at, which is what a caller computing a default chart range actually wants.

    min and max are the all-time extremes, with no time predicate. /summary also reports a min and a max, but over a window capped at 31 days, so they are not the same figures under a different name: on this sensor the all-time maximum is from September, four months outside any window /summary will accept. Ask /summary "how did it behave this week" and ask here "what is the most it has ever read".

    Both are null when the sensor has no non-null reading. That is an answer; a 404 there would be the same body an unknown sensor id gets.

    The text series figures are reported too. sensor_text_series is empty across the fleet, so they are 0 and null — reported rather than dropped, because "no text readings" is an answer and silence is not.

    Worth knowing

    The two series tables are counted independently. LEFT JOINing sensor_num_series_v2 and sensor_text_series and grouping multiplies them — a sensor with 100 numeric and 3 text readings reports num_series_count of 300. Separate scans make that unrepresentable rather than merely unobserved.

    The bounds use an ordered LIMIT 1, not min()/max(). Measured on the hypertable: 108ms and 64ms against 408ms for min(ts), because the index walk stops at the first row while the aggregate visits every chunk.

    The extremes sort nulls last. ORDER BY val DESC puts nulls first in Postgres, which returns a row carrying a timestamp and a null value — presented as the maximum — on any sensor that has ever recorded one. Ties break on ts ASC, so a value hit twice reports the same timestamp on every call.

    The count and both extremes come from one aggregate pass. There is no index on (sensor_id, val), so an ordered LIMIT 1 on val cannot stop early — it scans the sensor's rows and sorts them. Measured on this sensor, a separate max was 854ms and a separate min 294ms, and this route was 935ms before the extremes were folded in. One pass carrying all three is 382ms, so the route gained two figures and got faster than it was without them.

    a minute of staleness changes nothing a caller charting months would see.

    Errors

    400invalid_paramsensor_id is not a UUID
    404not_foundno sensor with that id
    Security
    a read behind the v2 capability gate (`v2` + `read`, no role).
    Cost
    0.4s — one aggregate pass plus two bounded index scans.
    Cache
    slow tier. The extent moves with the ingest cadence at one end, but
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/00000a49-28ff-481b-a787-5ab8ad7da500/series" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "sensor_num_series_v2",
        "class": "measured",
        "as_of": "2026-11-07T15:30:00Z",
        "coverage": { "from": "2026-03-29T06:20:00Z", "to": "2026-11-07T15:30:00Z" }
      },
      "item": {
        "first_at": "2026-03-29T06:20:00Z",
        "last_at": "2026-11-07T15:30:00Z",
        "count": 63289,
        "min": { "ts": "2026-05-23T16:40:00Z", "val": -55.3638 },
        "max": { "ts": "2026-09-16T23:50:00Z", "val": 4168.8698 },
        "span_days": 223.44444444444446,
        "text_count": 0,
        "text_first_at": null,
        "text_last_at": null
      }
    }
    Try it in the Explorer

    Hourly Stats

    GET/api/v2/sensors/{sensor_id}/stats

    Hourly aggregates for a sensor, from the sensor_stats_1h continuous aggregate.

    Path parameters

    • sensor_idrequirede.g. 00000a49-28ff-481b-a787-5ab8ad7da500

    Query parameters

    • limitrequirede.g. 100

      default 1000, max 5000.

    • fromoptionale.g. 2026-11-06
    • tooptionale.g. 2026-11-07
    • diroptionale.g. asc

      asc (default) or desc.

    • offsetoptionale.g. 0

      default 0.

    Each bucket carries n, avg, min, max, stddev, first and last for that hour. Buckets outside the aggregate's refresh window are immutable, so paging a fixed from/to is stable.

    Worth knowing

    from/to accept a bare date as well as RFC 3339, as on every other route here — ?from=2026-11-01 should not be a 400 on one route and valid on the rest.

    The span is capped at the aggregate's retention. Accepting any range means a window reaching past 90 days returns a partial answer with nothing saying it was truncated by retention rather than by the sensor being silent — so an empty window says so and names the 90 days.

    sort and dir are both accepted and echoed, so a caller can confirm the order it got.

    meta.coverage is the span the buckets actually cover, and a full page warns that the window continues past the last bucket.

    The window is half-open, so adjacent pages do not both contain the boundary bucket.

    Errors

    400invalid_paramsensor_id not a UUID; unparseable from/to; dir not asc/desc; limit or offset not a positive integer
    400window_too_largespan longer than 90 days
    400limit_exceededlimit above 5000
    404not_foundno sensor with that id
    Security
    a read behind the v2 capability gate (`v2` + `read`, no role).
    Cost
    0.2s.
    Cache
    slow tier.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/00000a49-28ff-481b-a787-5ab8ad7da500/stats?limit=100" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "sensor_stats_1h",
        "class": "computed",
        "as_of": "2026-11-07T14:00:00Z",
        "coverage": { "from": "2026-11-06T15:00:00Z", "to": "2026-11-07T14:00:00Z" },
        "count": 22, "limit": 100, "offset": 0, "total": 22,
        "sort": "bucket", "dir": "asc",
        "notes": ["Hourly buckets from the sensor_stats_1h continuous aggregate, which retains 90 days. Buckets outside the refresh window are immutable, so paging a fixed from/to is stable."]
      },
      "items": [
        { "bucket": "2026-11-06T15:00:00Z", "n": 12, "avg": 29.4291,
          "min": 25.9793, "max": 43.0219, "stddev": 4.9935,
          "first": 27.2248, "last": 26.8524 }
      ]
    }
    Try it in the Explorer

    Summary

    GET/api/v2/sensors/{sensor_id}/summary

    Every scalar aggregate for a sensor over one window.

    Path parameters

    • sensor_idrequirede.g. 00000a49-28ff-481b-a787-5ab8ad7da500

    Query parameters

    • fromoptionale.g. 2026-11-06
    • tooptionale.g. 2026-11-07

    THE DEFECT THIS FIXES

    Every figure here covers the same window, and the window is stated. Splitting these across routes is how they come to describe different periods without saying so: an unbounded min and max — ORDER BY val LIMIT 1 over the sensor's entire history — beside an average over the last 24 hours. Measured on SPP's Real-Time LMP at lepa, 2026-11-07:

    /min    -55.3638  at 2026-05-23     all time
    /max   4168.8698  at 2026-09-16     all time
    /avg      26.63                     the last 24 hours

    Read as the triple they look like, that is a day's mean sitting between two all-time extremes. A client drawing a gauge from them puts the needle at 26 on a scale of -55 to 4169. Here every figure comes from one pass over one window, and meta.coverage states it.

    Bounding the extremes also makes them cheap: unbounded those scans measure 0.44s and 0.51s, and three separate calls cost 1.16s against 0.52s for this one.

    The sensor id is a path UUID and the window goes through respond.ParseWindow; both bounds reach Postgres as bound parameters.

    Also worth knowing

    One request, not three, and every figure carries its context. count and nulls are here because without them an average could be over one reading or ten thousand.

    range is served rather than left to the caller, because deriving it from separately-windowed figures is what produces the -55 to 4169 scale above.

    Every figure is an explicit null on an empty window, and count is 0. A 404 there would be the same body as an unknown sensor id, which is a different fact.

    Extremes carry their timestamps, and ties resolve to the earliest, so two requests over one window cannot disagree about when the maximum fell.

    A valueless reading is counted in count and in nulls and excluded from the averages, so "a reading arrived with no value" stays visible.

    Errors

    400invalid_paramsensor_id not a UUID; unparseable from/to
    400window_too_largespan longer than 31 days
    404not_foundno sensor with that id
    Security
    a read behind the v2 capability gate (`v2` + `read`, no role).
    Cost
    0.52s for a day of 5-minute data, one scan.
    Cache
    slow tier — a summary of a window, not a current value.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/00000a49-28ff-481b-a787-5ab8ad7da500/summary" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "sensor_num_series_v2",
        "class": "computed",
        "as_of": "2026-11-07T14:50:00Z",
        "coverage": { "from": "2026-11-06T14:54:11Z", "to": "2026-11-07T14:54:11Z" }
      },
      "item": {
        "count": 288,
        "nulls": 0,
        "min":   { "ts": "2026-11-07T09:40:00Z", "val": 13.8077 },
        "max":   { "ts": "2026-11-06T22:50:00Z", "val": 68.855 },
        "first": { "ts": "2026-11-06T14:55:00Z", "val": 26.2738 },
        "last":  { "ts": "2026-11-07T14:50:00Z", "val": 22.6468 },
        "avg": 26.397388194444453,
        "stddev": 5.728007349946826,
        "p95": 34.14809,
        "p99": 45.720601999999985,
        "range": 55.04730000000001
      }
    }
    Try it in the Explorer

    Fleet Health

    GET/api/v2/sensors/health

    Which sensors are reporting and which have gone quiet.

    Query parameters

    • statusrequirede.g. stale

      healthy, stale or unknown.

    • limitrequirede.g. 50

      default 100, max 1000.

    • network_idoptionale.g. cbace340-e890-441f-b2ce-813706bbddf4

      restrict to one market.

    • node_idoptionale.g. 1fae9137-80bc-43cf-b39b-780808bdebe2

      restrict to one node.

    • sortoptionale.g. name

      name (default), id, status, row_count, ts, val.

    • diroptionale.g. asc

      asc or desc.

    • offsetoptionale.g. 0

      default 0.

    Status is computed by the sensor_num_series_health view from each sensor's last reading and its staleAfter tag:

    • healthy — reported within its threshold
    • stale — has not
    • unknown — carries no staleAfter tag, or has never reported

    unknown is the absence of a judgement, not a healthy one, and a client treating it as healthy misses exactly the sensors nobody is watching. A page containing any raises a warning counting them.

    status is allow-listed; the network and node filters are parsed as UUIDs before they reach the query.

    Worth knowing

    There is a total, so a caller paging the stale sensors can tell how many there are. On production right now that figure is 18,062 of 172,691.

    age_seconds and stale_after_seconds are integers. Returning an age as "1m4.046475347s" and a threshold as the raw tag text "30m" means a client parses two different interval formats to compare them. Both are seconds here, and last_reading_at is the timestamp they derive from.

    readings_counted, not row_count. The figure comes from sensor_num_series_count, a materialized view, and on 00000a49 it reads 14,291 against a live count of 63,263 — 77% low. row_count reads as exact; this name and the note say otherwise, and point at /summary for a figure computed over a window. Filed as #164.

    One naming convention: snake_case, and status here and on the per-sensor route. One field set should not have two spellings and two names for the same value.

    The ordering is total: every sort ends in the sensor id, so paging 18,062 stale sensors cannot repeat or skip one.

    Errors

    400invalid_paramstatus not one of the three; network_id/node_id not a UUID; sort unknown; limit or offset not a positive integer
    400limit_exceededlimit above 1000
    Security
    a read behind the v2 capability gate (`v2` + `read`, no role).
    Cost
    1.1s filtered, which is the exact count over the view.
    Cache
    slow tier.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/health?status=stale&limit=50" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "sensor_num_series_health",
        "class": "computed",
        "count": 1, "limit": 1, "offset": 0, "total": 18062,
        "sort": "name", "dir": "asc",
        "notes": ["readings_counted comes from sensor_num_series_count, a materialized view refreshed on a schedule, so it lags the live table. For an exact count over a window use /sensors/{id}/summary."]
      },
      "items": [
        {
          "sensor_id": "01d34c1c-a610-4ef3-aad9-cfa49939647d",
          "sensor_name": "Day-Ahead LMP",
          "status": "stale",
          "last_reading_at": "2026-11-01T06:00:00Z",
          "age_seconds": 550859,
          "last_value": 51.32821,
          "stale_after_seconds": 86400,
          "readings_counted": 2952
        }
      ]
    }
    Try it in the Explorer

    Latest (batch)

    GET/api/v2/sensors/latest

    Current reading for many sensors in one request.

    Query parameters

    • idsrequirede.g. 18f22a1e-fd14-49d5-8b5c-4cd648d22b39,0e6c8eeb-b649-4616-8fbe-9f11a81eeae9

      comma-separated sensor UUIDs (required, max 200)

    /sensors/{id}/cur is fine for one sensor and costs one request per sensor for a watchlist. This is the batch form.

    Notes

    • Ids that return no reading are counted in meta.warnings rather than dropped silently, so a caller need not diff request against response.
    • Duplicate ids are collapsed.
    • Reads sensor_num_series_latest, the trigger-maintained table that exists so "latest value" never scans the hypertable.

    Errors

    400missing_paramids not supplied
    400invalid_paramone or more ids are not UUIDs — detail.invalid lists them
    400limit_exceededmore than 200 ids (detail.requested, detail.max)
    Cache
    live tier, 60s.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/sensors/latest?ids=18f22a1e-fd14-49d5-8b5c-4cd648d22b39,0e6c8eeb-b649-4616-8fbe-9f11a81eeae9" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "sensor_num_series_latest",
        "class": "measured",
        "as_of": "2026-08-27T13:25:00Z",
        "count": 2,
        "limit": 200,
        "warnings": ["no current reading for 1 of 3 ids"]
      },
      "items": [
        {
          "sensor_id": "18f22a1e-fd14-49d5-8b5c-4cd648d22b39",
          "sensor_name": "Load",
          "unit": "MW",
          "value": 19153.2235,
          "at": "2026-08-27T13:06:00Z",
          "age_seconds": 1121
        }
      ]
    }
    Try it in the Explorer