Nodes
The places sensors live — plants, substations, zones — and how they relate.
| GET | /nodes | List Nodes |
| GET | /nodes/{node_id} | Get Node |
| GET | /nodes/{node_id}/geometry | Node Geometry |
| GET | /nodes/{node_id}/relationships | Node Relationships |
| POST | /nodes/{node_id}/relationships | Create Node Relationship |
| DEL | /nodes/{node_id}/relationships/{relationship_id} | Delete Node Relationship |
List Nodes
/api/v2/nodesEvery node, with its network and type resolved inline.
Query parameters
limitrequirede.g. 50offsetoptionale.g. 0qoptionale.g. madisonnetwork_idoptionale.g. 024fe0c3-8d49-4624-855e-27e4882f90dfnode_typeoptionale.g. pricing-nodehas_geometryoptionale.g. truesortoptionale.g. namediroptionale.g. asc
And makes two more unnecessary, because they are a filter on sensors rather than a property of a node: /api/nodes/{id}/sensors -> /api/v2/sensors?node_id={id} /api/nodes/{id}/sensors/count -> meta.total on that same request
Filters, all optional and all bound parameters: ?q= full text over node_search (name, description, network) ?network_id= one market's nodes ?node_type= the slug, e.g. pricing-node, zone, undefined ?has_geometry= true or false — which nodes have a footprint
Sort: relevance, name, description, tz, node_type, sensor_count, created_at, updated_at, network_id, id. Default id asc, or relevance desc when ?q= is set, because a caller searching wants the best match first.
sensor_count is what /nodes/{id}/sensors/count returns, inline.
has_geometry says whether /nodes/{id}/geometry has anything, so a yes/no
question does not cost a polygon fetch — up to 9,840 kB for one bit. A page
of 100 nodes carrying both measured 101ms.
lat and lon are explicit nulls. Most nodes have no coordinates, and
omitting the fields would make a node at 0,0 indistinguishable from a node
with no location.
Every filter is a bound parameter — the query text reaches websearch_to_tsquery as $3 rather than being concatenated, so a value carrying tsquery punctuation is parsed as search text and cannot reach the statement. Data class: reference topology, no readings.
node list, a daily-at-most event.
Worth knowing
One shape for listing and searching. ?q= is a filter, not a separate
endpoint projecting different columns under different names — so a search
result can be handed to the same code that reads a listing result.
network is nested on
every item, and relevance is 0 when no query was asked.
/nodes/search returns a bare array — no count, no limit, no offset — so a caller cannot tell a page that ended from a collection that did.
/nodes/search swallows a bad ?limit=. strconv.Atoi failing silently
substitutes 50, so ?limit=abc is answered rather than refused. Here it is
refused.
/nodes/search orders by ts_rank alone. Full-text ranking ties in quantity, and two tied rows may swap between consecutive pages, so paging repeats and skips nodes. Every ordering here ends in the primary key.
The ids are nested, not dropped. network_id and node_type_id are
inside network{} and node_type{}, alongside the name the caller
actually wanted. node_type.slug is the value ?node_type= accepts, so a
caller can filter by what it was just handed rather than resolving a UUID
through /api/v2/ref/node-types first.
Filter names are snake_case, like the sort fields — one convention per query string.
?sort=relevance without ?q= is refused rather than answered with every node ranked 0.
Errors
| 400 | invalid_param | network_id is not a UUID |
| 400 | invalid_param | has_geometry is not true or false |
| 400 | invalid_param | sort or dir is not one of the advertised values |
| 400 | invalid_param | sort=relevance with no ?q= |
| 400 | limit_exceeded | limit above 1000, or q longer than 200 characters |
- Security
- a read behind the v2 capability gate (`v2` + `read`, no role).
- Cost
- 101ms for 100 rows including sensor_count and has_geometry.
- Cache
- static tier. Node topology changes when a market publishes a new
curl "https://utility-api-86672132515.us-east1.run.app/api/v2/nodes?limit=50" \
-H "Authorization: $GRIDBASE_API_KEY"{
"meta": {
"source": "node",
"class": "reference",
"count": 2, "limit": 2, "offset": 0, "total": 51811,
"sortable": ["relevance","name", ...],
"sort_directions": ["asc","desc"]
},
"items": [
{
"id": "00006c06-a39c-4eb4-ba9a-4108490d1d41",
"name": "SG_GNODESGCT3",
"description": "",
"tz": "America/Los_Angeles",
"lat": 32.55145469132008,
"lon": -111.29962159300999,
"network": { "id": "024fe0c3-...", "name": "caiso" },
"node_type": { "id": "6f592c0d-...", "slug": "undefined", "name": "Undefined" },
"sensor_count": 2,
"has_geometry": false,
"relevance": 0,
"created_at": "2025-04-19T12:11:13.827424Z",
"updated_at": "2025-05-30T15:02:27.902561Z"
}
]
}Get Node
/api/v2/nodes/{node_id}One node.
Path parameters
node_idrequirede.g. 00006c06-a39c-4eb4-ba9a-4108490d1d41
The item is the same shape the listing returns, read through the same scan list, so a caller can hand an item from either route to the same code. The statement binds one parameter and references no others — a gap in the parameter numbering is an error Postgres reports rather than ignores, and this has produced a 500 twice elsewhere in v2.
relevance is 0 here, there being no query to rank against. It is present
rather than omitted so the shape matches the listing exactly.
Data class: reference topology, no readings.
Worth knowing
404 carries {"code":"not_found"} and the request id, so a client can
branch on it rather than match prose.
network and node_type are resolved to names, not left as two UUIDs.
Errors
| 400 | invalid_param | node_id is not a UUID |
| 404 | not_found | no node with this id |
- Security
- a read behind the v2 capability gate (`v2` + `read`, no role).
- Cache
- static tier.
curl "https://utility-api-86672132515.us-east1.run.app/api/v2/nodes/00006c06-a39c-4eb4-ba9a-4108490d1d41" \
-H "Authorization: $GRIDBASE_API_KEY"Node Geometry
/api/v2/nodes/{node_id}/geometryOne node's footprint, as GeoJSON.
Path parameters
node_idrequirede.g. ad0cf647-6aa3-46cb-83ba-c8c1a392fd3d
Query parameters
formatrequirede.g. bboxsimplifyoptionale.g. 0.001
?format=geojson the full geometry (default) ?format=bbox the bounding box alone, no geometry ?simplify=<deg> one of 0.0001, 0.001, 0.01, 0.1 — written exactly so
Measured on the largest node in the dataset
full 9,840 kB 374,627 points
?simplify=0.001 1,041 kB 38,580 points
?simplify=0.01 611 kB
?format=bbox 169 B
On the San Diego node in this example the full response is 217,896 bytes and ?simplify=0.001 is 18,888 — 11.5× smaller.
Nothing is dropped to get there: the default is the full, unsimplified
geometry, and meta.warnings says when a response was simplified.
bbox is always populated, including beside the full geometry — it is 169
bytes and it is what a caller needs to fit a map to the node, so making it
a second request would be a request for 169 bytes. It is computed from the
unsimplified geometry, so a simplified response still reports a box that
contains the real footprint.
points and points_full are the vertex counts of what was returned and
of what is stored, so a caller can tell whether its tolerance did anything.
With ?format=bbox, points is 0 — nothing was returned to count —
and points_full is what you would have received.
simplify takes one of four fixed tolerances, written exactly as listed —
0.0010 and 1e-3 are refused even though they equal 0.001. That is a
cache property, not pedantry: the response cache keys on the full URL, so
every accepted spelling is a separate entry holding the same megabyte, and
there are infinitely many ways to spell a float. Four spellings means four
entries per node and a cache hit on the second request. Anything off the
ladder is refused rather than snapped to the nearest rung, because snapping
would report a tolerance the caller never sent.
Simplification uses ST_SimplifyPreserveTopology, not ST_Simplify. The plain
simplifier can produce self-intersecting rings and invalid polygons, which a
client then fails to render; the topology-preserving form costs more and
returns something drawable. A simplified geometry is an approximation and
meta.warnings says not to use it for containment tests.
A request with no tolerance returns the stored column rather than calling the simplifier with a no-op value: ST_SimplifyPreserveTopology at tolerance 0 still rebuilds the geometry, which on 374,627 points is work for no change.
The tolerance is the one numeric a caller controls and the statement types it float8, so it cannot reach the SQL text. Data class: reference topology, no readings.
zone, a yearly event.
Worth knowing
The GeoJSON is JSON, not a string. ST_AsGeoJSON returns text, so
scanning it straight through serialises the field as an escaped string —
"geometry": "{\"type\":\"MultiPolygon\",..." — which costs 217,651
bytes of escaping on this node and makes a caller parse the body and then
parse the field again.
It is one item, not a page. entity_geometry holds at most one row per
node — 7,642 rows with target_type 'node', 0 nodes with more than one — so
there is no collection here to page, and no limit/offset.
A node with no footprint and a node that does not exist are two different 404 bodies. One is a gap in the data and the other is a bad id.
Note on the data: 20 of those 7,642 rows point at a node id that no longer
exists. entity_geometry.target_id is polymorphic and carries no foreign
key, so a deleted node leaves its footprint behind. That is why
/api/v2/nodes?has_geometry=true totals 7,622 and not 7,642 — a data issue
upstream of this endpoint, not something it can fix.
Errors
| 400 | invalid_param | node_id is not a UUID |
| 400 | invalid_param | simplify is not one of 0.0001, 0.001, 0.01, 0.1 written exactly |
| 400 | invalid_param | format is not geojson or bbox |
| 400 | invalid_param | simplify sent with format=bbox, which returns no geometry |
| 404 | not_found | no node with this id |
| 404 | not_found | the node exists but has no geometry recorded |
- Security
- a read behind the v2 capability gate (`v2` + `read`, no role).
- Cache
- static tier. A node's footprint changes when a market redraws a
curl "https://utility-api-86672132515.us-east1.run.app/api/v2/nodes/ad0cf647-6aa3-46cb-83ba-c8c1a392fd3d/geometry?format=bbox" \
-H "Authorization: $GRIDBASE_API_KEY"{
"meta": {
"source": "entity_geometry",
"class": "reference",
"warnings": ["format=bbox returned the bounding box only; ..."]
},
"item": {
"node_id": "ad0cf647-6aa3-46cb-83ba-c8c1a392fd3d",
"kind": "MultiPolygon",
"geometry": { "type": "MultiPolygon", "coordinates": [[[[-117.129606, 32.621930001], ...]]] },
"bbox": {
"min_lon": -117.747409999759, "min_lat": 32.5343117407047,
"max_lon": -116.103139999999, "max_lat": 33.5051259999
},
"points": 38580,
"points_full": 374627,
"simplify": 0.001
}
}Node Relationships
/api/v2/nodes/{node_id}/relationshipsOne node's edges in the node graph, paged.
Path parameters
node_idrequirede.g. b50b9e42-fb05-43ec-bdf9-a6c2850bd223
Query parameters
limitrequirede.g. 25offsetoptionale.g. 0directionoptionale.g. bothkindoptionale.g. located_insortoptionale.g. created_atdiroptionale.g. desc
?direction=both|from|to ?kind=<slug> e.g. located_in, feeds, aggregates
Sort: created_at, updated_at, kind, peer_name, weight, id. Default created_at desc.
direction is relative to the node in the path: "outbound" when it is the
from end, "inbound" when it is the to end, "undirected" for a symmetric
kind, where the stored order is canonical rather than meaningful.
peer is the other end — the node this one is related to. from and to
are the stored orientation, kept so a caller reading one node's edges and a
caller reading the raw graph see the same thing.
kind.direction and kind.weighted are the two properties that govern what
a POST may say: a weighted: "yes" kind requires a weight, a "no" kind
refuses one, and "optional" takes either.
Every filter is a bound parameter. Data class: reference topology, no readings.
60s-old snapshot that does not contain the edge they just created.
Worth knowing
It pages, and limit refuses above 1000 rather than clamping. Unpaged,
the PJM zone node AEP's 3,191 relationships are 4,085,607 bytes — 4 MB — in
one response, because each row would embed two complete node records plus
the full kind record. Seven nodes are over a thousand edges, so "what is
AEP located in" should not cost 4 MB.
The orientation is computed for you. direction and peer say which way
round each edge is relative to the node you asked about, done in SQL —
otherwise code rendering "AEP's relationships" compares each row's node ids
against the id it just sent.
The ordering is total, ending in the primary key. The ingest jobs write
relationships in bulk — all 3,191 of AEP's share one created_at — so
ordering on that alone means ties, and ties mean rows swapping between
pages.
The embedded nodes are narrowed, not dropped. peer, from and to carry
id, name, lat and lon — enough to label and plot an edge without a request
per node. The full node record is /api/v2/nodes/{id}.
An empty result says which filter emptied it, and a 404 distinguishes
an unknown node from a node with no edges — {"count":0,"items":[]} for
both facts tells a caller neither.
Errors
| 400 | invalid_param | node_id is not a UUID |
| 400 | invalid_param | direction is not both, from or to |
| 400 | invalid_param | sort or dir is not one of the advertised values |
| 400 | limit_exceeded | limit above 1000 |
| 404 | not_found | no node with this id |
- Security
- a read behind the v2 capability gate (`v2` + `read`, no role).
- Cache
- no-store. A graph a caller is editing must not be served from a
curl "https://utility-api-86672132515.us-east1.run.app/api/v2/nodes/b50b9e42-fb05-43ec-bdf9-a6c2850bd223/relationships?limit=25" \
-H "Authorization: $GRIDBASE_API_KEY"{
"meta": {
"source": "node_relationship", "class": "reference",
"count": 2, "limit": 2, "offset": 0, "total": 3191,
"warnings": ["more relationships remain beyond this page; ..."]
},
"items": [
{
"id": "001face5-f196-43b7-b83a-279b8ae6ccd7",
"kind": {
"id": "506b299d-65c6-4c25-82e4-ddeeda630065",
"slug": "located_in", "name": "Located In",
"direction": "asymmetric", "weighted": "no"
},
"direction": "inbound",
"peer": { "id": "88729599-...", "name": "PROGRESS138 KV T1",
"lat": 36.96108746400006, "lon": -81.00360187899997 },
"from": { "id": "88729599-...", "name": "PROGRESS138 KV T1", "lat": ..., "lon": ... },
"to": { "id": "b50b9e42-...", "name": "AEP", "lat": ..., "lon": ... },
"weight": null,
"description": "From the zone in the node's PJM description",
"created_at": "2026-10-08T10:42:54.590295Z",
"updated_at": "2026-10-08T10:42:54.590295Z"
}
]
}Create Node Relationship
/api/v2/nodes/{node_id}/relationshipsAdd an edge to the node graph.
Path parameters
node_idrequirede.g. b50b9e42-fb05-43ec-bdf9-a6c2850bd223
Body
to_node_id required, UUID, must differ from the path node
kind required, a slug from /api/v2/ref/node-relationship-kinds
weight required for a weighted: "yes" kind, refused for "no"
description optional free text
Returns 201 with the created edge in the listing's shape, read back through
the same projection, so the direction and peer are oriented relative to
the path node.
write capability AND the subject to hold the contributor role — an
intersection, not a fallback: the token says what the credential may do, the
role says what the user may do, and neither widens the other. No
auth.RequireRole on the route; the group already asks. The role is read
per request rather than cached, because a cached role meant a revoked
contributor kept writing for a minute.
Verified: with a read-only token this returns 403 {"code":"forbidden","detail":{"required_access":"write","token_access":"read"}} before the handler body runs — no INSERT is reached.
Every value is a bound parameter. Data class: reference topology, written by a contributor.
A symmetric kind stores its pair in a canonical order (the lower UUID first), so A→B and B→A are one row rather than two records of one fact and the UNIQUE (from_node_id, to_node_id, kind_id) sees the duplicate.
Worth knowing
Every rejection names the field and carries the rule, so it is branchable
rather than prose:
{"code":"invalid_param","field":"weight","detail":{"kind":"feeds","weighted":"yes"}}.
An unknown kind names where the list is rather than only echoing the slug.
A foreign-key violation does not blame to_node_id outright. Neither end
is checked before the insert, so either one can be the missing node, and
naming only the body field would send a caller looking at the wrong id.
Errors
| 400 | invalid_param | node_id or to_node_id is not a UUID |
| 400 | invalid_param | to_node_id equals the path node (no self-loops) |
| 400 | invalid_param | kind is missing, or not one this deployment defines |
| 400 | invalid_param | weight missing on a weighted kind, or set on an unweighted one |
| 400 | invalid_param | one of the node ids does not exist |
| 403 | forbidden | token is read-only, or the subject lacks the contributor role |
| 409 | conflict | these two nodes already have a relationship of this kind |
- Security
- this is a WRITE. The v2 group gate requires the token to carry
curl -X POST "https://utility-api-86672132515.us-east1.run.app/api/v2/nodes/b50b9e42-fb05-43ec-bdf9-a6c2850bd223/relationships" \
-H "Authorization: $GRIDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to_node_id": "0d86b4e4-c747-42ac-823b-efbe6e3412c2",
"kind": "adjacent_to",
"description": "shares a tie line"
}'Delete Node Relationship
/api/v2/nodes/{node_id}/relationships/{relationship_id}Remove an edge from the node graph.
Path parameters
node_idrequirede.g. b50b9e42-fb05-43ec-bdf9-a6c2850bd223relationship_idrequirede.g. 001face5-f196-43b7-b83a-279b8ae6ccd7
Returns 200 with {"item": {"id": "...", "deleted": true}}, matching the shape the other deletes use. A 204 with no body cannot carry a request id.
The edge must touch the path node or the answer is 404 — otherwise the route confirms the existence of relationships between nodes the caller did not ask about.
contributor role on the subject, as an intersection.
Verified: with a read-only token this returns 403 {"code":"forbidden","detail":{"required_access":"write","token_access":"read"}} before the handler body runs — no DELETE is reached.
Worth knowing
One statement, not read-then-write. The ownership predicate is in the DELETE itself, with RETURNING to report whether anything matched — reading the row, checking it in Go and then deleting leaves a window in which the row can change between the check and the delete.
Errors
| 400 | invalid_param | node_id or relationship_id is not a UUID |
| 403 | forbidden | token is read-only, or the subject lacks the contributor role |
| 404 | not_found | no relationship with this id on this node |
- Security
- this is a WRITE. `write` capability on the token AND the
curl -X DELETE "https://utility-api-86672132515.us-east1.run.app/api/v2/nodes/b50b9e42-fb05-43ec-bdf9-a6c2850bd223/relationships/001face5-f196-43b7-b83a-279b8ae6ccd7" \
-H "Authorization: $GRIDBASE_API_KEY"