sl.subgraphs
Deploy a subgraph, read its rows and watch its operations. The same data the Subgraphs API serves over HTTP.
| list() | { data: SubgraphSummary[] } | List the subgraphs deployed to this instance. |
| status(name) | SubgraphDetail | Get a subgraph's health, sync position, and tables. |
| openapi(name, options) | Record<string, unknown> | Get a subgraph's OpenAPI spec. |
| schema(name, options) | SubgraphAgentSchema | Get a subgraph's schema as JSON, shaped for agents. |
| markdown(name, options) | string | Get a subgraph's generated API docs as Markdown text. |
| reindex(name) | ReindexResponse | Rebuild a subgraph from scratch. |
| stop(name) | { message: string; operationId?: st… | Stop a running reindex or backfill. |
| backfill(name, options) | ReindexResponse | Process one block range. |
| gaps(name, opts) | SubgraphGapsResponse | List the block ranges a subgraph is missing. |
| delete(name, options) | { message: string } | Delete a subgraph and its tables. |
| rows(name, table, params) | SubgraphRowsEnvelope<T> | Read a table's rows, one cursor page at a time. |
| operations(name) | { operations: SubgraphOperationStat… | Recent reindex/backfill operations for a subgraph, newest first. |
| getOperation(name, operationId) | SubgraphOperationStatus | Get the status of one reindex, backfill, or stop operation. |
| deploy(data) | DeploySubgraphResponse | Create or update a subgraph. |
| getSource(name) | SubgraphSource | Get a deployed subgraph's source. |
| bundle(data) | BundleSubgraphResponse | Bundle a TypeScript subgraph source on the server. |
| count(name, table, params) | { count: number } | Count the rows in a table that match a filter. |
| aggregate(name, table, params) | SubgraphAggregateResponse | Compute scalar aggregates over a table's matching rows. |
| typed(def) | InferSubgraphClient<T> | Returns a typed client for a subgraph defined with defineSubgraph(). |
List the subgraphs deployed to this instance.
Each summary has the status, the last processed block against the chain tip, progress, gapCount, and an integrity flag.
Get a subgraph's health, sync position, and tables.
The verify step after a deploy, reindex, or backfill: poll it until sync catches the tip.
Parameters
hover a row to find it in the codeRequired
namerequiredstring |
Returns Promise<SubgraphDetail>
name- string
version- string
schemaHash- string
pin- sha256 over schema, handler bundle, startBlock, network and runtime. Null for subgraphs deployed before pins existed.
verification- Null for subgraphs deployed before levels were derived.
status- string
lastProcessedBlock- number
description- string
sources- Record<string, unknown>
definition- Record<string, unknown>
health- { totalProcessed: number; totalErrors: number; errorRate: number; lastError: st…
sync- SubgraphSyncInfo
tables- Record<string, { endpoint: string; columns: Record<string, { type: string; null…
createdAt- string
updatedAt- string
sl.subgraphs.openapi(name, options)
Get a subgraph's OpenAPI spec.
Describes the REST routes generated for each table. Pass serverUrl to set the server the spec advertises.
Parameters
hover a row to find it in the codeRequired
namerequiredstring |
Options
options.serverUrlstring | |
options.generatedAtstring |
sl.subgraphs.schema(name, options)
Get a subgraph's schema as JSON, shaped for agents.
Per table: the endpoints, columns, indexes, which fields are sortable, selectable, searchable, or filterable, and a ready example query. Pass serverUrl to set the server the endpoints use.
Parameters
hover a row to find it in the codeRequired
namerequiredstring |
Options
options.serverUrlstring | |
options.generatedAtstring |
Returns Promise<SubgraphAgentSchema>
name- string
version- string
description- string
schemaHash- string
pin- string
generatedAt- string
serverUrl- string
sources- Record<string, unknown>
tables- Record<string, { endpoint: string; countEndpoint: string; aggregateEndpoint?: s…
sl.subgraphs.markdown(name, options)
Get a subgraph's generated API docs as Markdown text.
Pass serverUrl to set the server the examples use.
Parameters
hover a row to find it in the codeRequired
namerequiredstring |
Options
options.serverUrlstring | |
options.generatedAtstring |
Rebuild a subgraph from scratch.
A reindex always drops and rebuilds the whole subgraph, so it takes no block range; the API rejects one with REINDEX_RANGE_NOT_SUPPORTED. Use backfill to process a specific range. While a reindex or backfill is already running the API answers 409 with code OPERATION_IN_PROGRESS; poll operations until it finishes.
Parameters
hover a row to find it in the codeRequired
namerequiredstring |
Returns Promise<ReindexResponse>
message- string
fromBlock- number
toBlock- string | number
operationId- string
status- "queued" | "running" | "cancel_requested"
Stop a running reindex or backfill.
Requests the cancel and resolves with the operationId and a cancel_requested status. Poll getOperation until status is terminal. Throws a 404 with code NO_OPERATION when nothing is running.
Parameters
hover a row to find it in the codeRequired
namerequiredstring |
Process one block range. 409 OPERATION_IN_PROGRESS while another reindex or backfill runs on this subgraph.
Parameters
hover a row to find it in the codeRequired
namerequiredstring | |
options.fromBlockrequirednumber | |
options.toBlockrequirednumber |
Returns Promise<ReindexResponse>
message- string
fromBlock- number
toBlock- string | number
operationId- string
status- "queued" | "running" | "cancel_requested"
List the block ranges a subgraph is missing.
Each gap has its start, end, size, reason, and when it was detected and resolved. resolved filters to resolved or open gaps; page with limit and offset. meta reports the total gap count and total missing blocks.
Parameters
hover a row to find it in the codeRequired
namerequiredstring |
Options
opts.limitnumber | |
opts.offsetnumber | |
opts.resolvedboolean |
Returns Promise<SubgraphGapsResponse>
data- SubgraphGapEntry[]
meta- { total: number; totalMissingBlocks: number; limit: number; offset: number }
Delete a subgraph and its tables.
Permanent. The API cancels any running reindex or backfill first, waits up to 5 seconds for it to stop, then drops the subgraph's tables and registry entry. force: true is sent as ?force=true.
Parameters
hover a row to find it in the codeRequired
namerequiredstring |
Options
options.forceboolean |
Read a table's rows, one cursor page at a time.
Anon works on an open instance; pass an apiKey on the client where reads are closed. next_cursor is set on every page that returned rows and is null only on an empty page, so a poller tails with cursor = page.next_cursor ?? cursor. A paging loop ends on an empty page (or one shorter than limit).
Parameters
hover a row to find it in the codeRequired
namerequiredstring | |
tablerequiredstring |
Options
params.limitnumber | |
params.filtersRecord<string, string> | |
params.fieldsstring | |
params.orderstring | |
params.sortstring | |
params.cursorstring |
Returns Promise<SubgraphRowsEnvelope<T>>
rows- T[]
next_cursor- Set on every page that returned rows;
nullonly on an empty page. tip- { block_height: number; subgraph_height: number; blocks_behind: number }
Recent reindex/backfill operations for a subgraph, newest first.
Parameters
hover a row to find it in the codeRequired
namerequiredstring |
sl.subgraphs.getOperation(name, operationId)
Get the status of one reindex, backfill, or stop operation.
Poll the operationId returned by reindex, backfill, or stop until status is terminal.
Parameters
hover a row to find it in the codeRequired
namerequiredstring | |
operationIdrequiredstring |
Returns Promise<SubgraphOperationStatus>
id- string
subgraphName- string
kind- "reindex" | "backfill"
status- "queued" | "running" | "completed" | "failed" | "cancelled"
fromBlock- number | null
toBlock- number | null
processedBlocks- number | null
progress- 0–1 fraction; null when no denominator is known yet. 1 when completed.
error- string | null
startedAt- string | null
finishedAt- string | null
createdAt- string
updatedAt- string
Create or update a subgraph. A deploy that needs a rebuild queues one; if a reindex or backfill is already running the API answers 409 with code OPERATION_IN_PROGRESS (an ApiError, not a dedicated class).
Parameters
hover a row to find it in the codeRequired
namerequiredstring | |
sourcesrequiredRecord<string, Record<string, unknown>> | |
schemarequiredRecord<string, unknown> | |
handlerCoderequiredstring |
Options
descriptionstring | |
startBlocknumber | Override the definition's startBlock for this deploy only. |
sourceCodestring | Original TypeScript source, persisted so chat can read/diff/edit later. |
dryRunboolean | Validate the definition + print the DDL plan without deploying. |
Returns Promise<DeploySubgraphResponse>
action- "created" | "unchanged" | "handler_updated" | "updated" | "reindexed"
subgraphId- string
version- string
message- string
start_block- Effective indexing start height.
operationId- string
reindexStarted- boolean
estimatedEvents- Bounded candidate-event denominator for the reindex just started, when the op was classifiable as sparse/light. Absent for heavy ops (no upfront estimate possible) — check
sl subgraphs statusafter ~30s for a rate-based ETA instead. warnings- Non-blocking deploy lints (e.g. handler reads a print field never observed on-chain).
pin- sha256 identity of what was deployed; absent on unbundled deploys.
verification- SubgraphVerification
diff- { addedTables: string[]; removedTables: string[]; addedColumns: Record<string, …
sl.subgraphs.getSource(name)
Get a deployed subgraph's source.
Returns sourceCode, the bundled handlerCode the runtime executes, and the pin hash of what you deployed. handlerCode and pin are null for local deploys. A subgraph deployed before source was captured returns sourceCode: null and readOnly: true with a reason; redeploy it to capture the source.
Parameters
hover a row to find it in the codeRequired
namerequiredstring |
Returns Promise<SubgraphSource>
name- string
version- string
sourceCode- string | null
handlerCode- The bundled handler the runtime executes; null for local deploys.
pin- sha256 of
pinPreimage; null for local deploys. pinPreimage- The canonical JSON the pin hashes (handler hash, network, runtime, schema hash, startBlock); null before it was stored.
readOnly- boolean
reason- string
updatedAt- string
Bundle a TypeScript subgraph source on the server. Used by the web chat authoring loop so Vercel's serverless runtime doesn't have to run esbuild.
Parameters
hover a row to find it in the codeRequired
coderequiredstring |
Returns Promise<BundleSubgraphResponse>
ok- true
name- string
description- string | null
sources- Record<string, Record<string, unknown>>
schema- Record<string, unknown>
handlerCode- string
sourceCode- string
bundleSize- number
Count the rows in a table that match a filter.
The count is exact. Same auth posture as rows.
Parameters
hover a row to find it in the codeRequired
namerequiredstring | |
tablerequiredstring |
Options
params.filtersRecord<string, string> |
Compute scalar aggregates over a table's matching rows.
Same auth posture as rows.
Parameters
hover a row to find it in the codeRequired
namerequiredstring | |
tablerequiredstring |
Options
params.filtersRecord<string, string> | |
params.countboolean | |
params.countDistinctstring[] | |
params.sumstring[] | |
params.minstring[] | |
params.maxstring[] |
Returns Promise<SubgraphAggregateResponse>
count- number
countDistinct- Record<string, number>
sum- Record<string, string>
min- Record<string, string | null>
max- Record<string, string | null>
Returns a typed client for a subgraph defined with defineSubgraph(). Row types are inferred from the subgraph's schema literal types.
Parameters
hover a row to find it in the codeRequired
defrequiredT |
BundleSubgraphResponseDeploySubgraphRequestDeploySubgraphResponseReindexResponseSubgraphAgentSchemaSubgraphAggregateParamsGET /v1/subgraphs/:subgraphName/:tableName/aggregate.SubgraphAggregateResponseSubgraphDetailSubgraphGapEntrystart, end, size, reason, detectedAt, resolvedAtSubgraphGapRangestart, end, size, reasonSubgraphGapsResponseSubgraphOperationStatusSubgraphRowsEnvelopeSubgraphSourceSubgraphSpecOptionsSubgraphSummarySubgraphSyncInfostatus, mode, startBlock, lastProcessedBlock, chainTip, sourceChainTip, …SubgraphVerification