Query EIA Route Data
eia_query_routeFetches data from a leaf route with optional facet filters, date range, frequency, and column selection. Use eia_describe_route first to discover valid facet IDs, facet values, column IDs, and frequency codes. Data values are strings in the response (EIA API returns all numeric values as strings, e.g. "9.13"); cast to DOUBLE in SQL when arithmetic is needed. Returns a preview inline and stages nothing by default — one upstream request, whatever total says. Pass stage: true to also page past the preview and stage the accumulated set as a DataCanvas table, then pass the returned dataset name to eia_dataframe_describe for its column names and eia_dataframe_query for SQL. Every dataset a tenant stages lands in the same canvas, so tables from different routes cross-join by name with nothing to thread between calls.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"route": "<route>"
},
"name": "eia_query_route"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | No | Period end, read the same way as start: a coarser end selects only its first period, so "2020" ends at 2020-01 at monthly — use "2020-12" to include the whole year. At hourly a date-only end covers its whole day. | |
| sort | No | Result ordering. | |
| route | Yes | Leaf route path (e.g. "electricity/retail-sales", "steo"). Discoverable via eia_browse_routes or eia_search_routes. Whitespace and slashes are normalized, then one complete leading v2 segment is removed: "/v2/electricity/retail-sales/" resolves to "electricity/retail-sales". A path naming an EIA endpoint is refused: pass the route before its data or facet segment ("petroleum/pri/spt", not "petroleum/pri/spt/data" or "petroleum/pri/spt/facet/series"), and give the ID of a seriesid/{id} path to eia_search_routes. Full URLs are not normalized. | |
| stage | No | Stage the matching rows as a DataCanvas table for SQL (default false). Off, the call makes one upstream request and returns the preview alone. On, the service pages past the preview up to the staging row cap this server sets and registers the accumulated rows, starting at offset, returning the handle in dataset — several extra upstream requests and seconds of latency on a large route, so turn it on when moving to analysis, not while exploring. Requires the server to have a canvas, which it does unless its operator turned it off; without one nothing is staged whatever this is set to. | |
| start | No | Period start in the route date format (e.g. "2020-01" for monthly, "2020" for annual). Format from eia_describe_route. EIA reads a bound as the period of the effective frequency containing its first day, so a coarser bound selects that one period ("2020" is 2020-01 at monthly, "2020-Q4" is 2020-10). At local-hourly every bound needs its hour and UTC offset (YYYY-MM-DDTHH±HH, e.g. "2024-02-01T02-06"). | |
| length | No | Rows per page. Default 25; a larger value returns at most 5,000 and says so. With stage: true, staging is not bounded by this — it pages past the page on its own. | |
| offset | No | Row offset into the matching set (default 0). An offset at or beyond total returns zero rows. | |
| columns | No | Data column IDs to return (reduces payload). Defaults to all. IDs discoverable via eia_describe_route data_columns[].id. Every row also carries period and each facet ID whatever this lists, so naming those here is unnecessary and they are dropped from the request. | |
| filters | No | Facet filters keyed by facet ID (e.g. { "stateid": "TX", "sectorid": ["RES", "COM"] }). Use the facets[].id values returned by eia_describe_route as keys here. Every value travels in the request URI, which EIA caps at about 8 KB — a few hundred values across all filters; split a longer list across calls. | |
| frequency | No | Aggregation frequency ID (e.g. "monthly", "annual"). Defaults to route default. Valid IDs from eia_describe_route. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | Inline rows: the length rows from offset, fewer only at the end of the matching set. All numeric values are strings per the EIA API (e.g. "9.13"). Cast to DOUBLE in SQL for arithmetic: CAST(value AS DOUBLE). Per-column units appear as {col}-units fields inline in each row. Keys are dynamic column IDs from the EIA route. | |
| error | No | Present when the call failed. Absent on success. | |
| route | No | The canonical route path queried: whitespace/slashes normalized and one complete leading v2 segment removed. Reusable verbatim in a follow-up call. | |
| total | No | Total matching rows in the EIA dataset for this query (may exceed returned rows when pagination or spillover applies). | |
| notice | No | Composed guidance for empty results or an offset past total, unmatched filter values in complete cached vocabularies, year-only bounds on effective monthly YYYY-MM data, a weekly or four-week-average bound whose hour past 23 EIA read as a later day past a period date, which moves the range by a week (or, with no rows, how EIA read it), and requested/effective length when clamped. Submitted filters and date bounds are preserved. | |
| dataset | No | df_<id> handle for the staged rows — eia_dataframe_describe lists its column names; eia_dataframe_query runs SQL over it (SELECT … FROM df_<id>). Present only when a stage: true call registered a table on a deployment with a canvas configured; absent otherwise, since nothing was staged. Every dataset a tenant stages shares one canvas, so handles from different routes join directly. | |
| frequency | No | Frequency of the returned data. | |
| appliedEnd | No | Echo of the end period as applied, when an end was provided. | |
| totalCount | No | Total matching rows in the EIA dataset. | |
| appliedSort | No | Echo of the result ordering as applied, when a sort was provided — the ordering that decided which rows a capped stage holds. | |
| date_format | No | Period format for the returned data (e.g. "YYYY-MM"). | |
| next_offset | No | Offset that continues right after the rows in data (offset + returned_count) — pass it as offset for the next page, with no gap or overlap. Present whenever rows remain past this page; absent on the last page. | |
| appliedStart | No | Echo of the start period as applied, when a start was provided. | |
| appliedLength | No | Rows per page applied to this call — length, after any clamp. | |
| appliedOffset | No | Row offset applied to the query — the cause when a page comes back empty. | |
| returnedCount | No | Rows in this response. When returnedCount < totalCount, continue at next_offset or stage the rest. | |
| appliedColumns | No | Echo of the column projection as sent to EIA, when columns named at least one data column — period and facet IDs, which every row carries anyway, are not part of it. | |
| appliedFilters | No | Facet filters applied to the query, when provided. | |
| effectiveRoute | No | The route path that was queried. | |
| returned_count | No | Number of rows in data. When returned_count < total, continue at next_offset or stage the rest for SQL. | |
| appliedFrequency | No | Echo of the frequency as applied, when a frequency was provided. | |
| truncation_warning | No | Upstream advisories forwarded verbatim from EIA's warnings[], joined with '; ' when more than one applies. These describe the inline page — EIA's "incomplete return" entry fires whenever the requested length is under total, at any size — not a 5,000-row ceiling on this response. Absent when the response already accounts for the gap the advisory names (the staged table reaches the last row, notice explains the empty page, or canvas_preview_note places the inline page against total because nothing was staged). | |
| canvas_preview_note | No | Human-readable note, present whenever dataset is set or staging failed, and otherwise when total exceeds the inline rows. On a stage: true call it opens with the stage outcome: the staged row count and dataset name, naming eia_dataframe_describe for the staged column names (quoting one rename when staging renamed a column) and then eia_dataframe_query for SQL — or, when the canvas failed, that no dataframe was created (dataset is then absent), with the retry — from offset 0 past the first page — and, while rows remain, offset paging. Next, where in the matching set the staged rows sit whenever the stage does not start at row 1, and when staging stopped short of total (the staging row cap this server sets, the time limit of the call, or an upstream page that did not return) the offset to resume from; last, the row range of the inline page (e.g. rows 21–30 of 55), whether it is the last page, and next_offset — and, after a registered stage, that the inline rows page with stage left off, since another stage: true call stages a new table. Where staging was not requested it names the row range of the inline page, says when it is the last page, and names stage: true and eia_dataframe_query as the way to get SQL access to the matching rows — with offset 0 past the first page, since a stage starts at offset — and offset paging while rows remain; where this server has no canvas, it says staging is unavailable on this deployment and, while rows remain, names offset paging instead. |