Skip to main content

HTTP API

Everything the CLI and web UI do goes through the Catchment's HTTP API. This page covers authentication, shared conventions and the available routes. For request and response bodies, every Catchment serves its own schema:

PathContents
/openapi.jsonThe OpenAPI schema.
/docsInteractive documentation (Swagger UI).
/redocReference documentation (ReDoc).

All routes below are under /api, apart from /metrics.

Authentication​

A Catchment is either open, or protected by API keys. An open Catchment treats every request as having full access. This is also the right setting when a hosting platform authenticates requests before they reach the Catchment.

With keys configured, send one as a bearer token:

curl -H "Authorization: Bearer $DUCKSTRING_KEY" http://127.0.0.1:7474/api/status

Keys come in three levels, each including the ones before it:

LevelAllows
readStatus, run history, lineage, data and catalog queries.
demandAlso Refreshes: refreshing now, and adding and removing recurring Refreshes.
fullEverything else: deploying, control actions, windows, Spouts, secrets, alerts, ducts, compute and Catchment settings.

A missing or unrecognised key gets 401; a key below the route's level gets 403. Tracebacks in run history are only returned to full keys; lower levels get the error message alone.

A Tap's key is a fourth kind, outside the levels. It is accepted only by /api/query, /api/serve/query, /api/serve and its own Pond's /freshness, where it reads the Pond's exposed tables (as a read-level key does) and its queries may send the Pond a Refresh, and gets 403 everywhere else. It works on an open Catchment too.

Conventions​

Targeting a major line. Routes that act on one Pond take the Pond name in the path and two optional query parameters:

ParameterDescription
majorThe major line. Defaults to the highest deployed.
versionA full version such as 1.2.0. Must be the major line's currently deployed version, otherwise 422.

Status codes.

CodeMeaning
401, 403Authentication, as above.
404Unknown Pond, table, Object, Spout, window or channel.
409The operation needs the Pond idle, or conflicts with its current state.
422Invalid input, including a deployment that breaks a version pin, and a failed confirmation for irreversible operations.

A connection test (/spouts/test, /alerts/{name}/test) that fails returns 200 with {"ok": false, "error": ...}, since the request itself succeeded.

Routes​

Catchment​

MethodPathLevelDescription
GET/api/healthnoneLiveness check.
GET/api/catchment/identityreadThe Catchment's name and id.
GET/api/catchment/settingsreadData root and cloud status.
PUT/api/catchment/settingsfullSet the data root.
GET/api/catchment/duck-poolsreadBuilt-in and defined pools.
POST/api/catchment/duck-poolsfullCreate or update a pool.
DELETE/api/catchment/duck-pools/{name}fullRemove a pool.
GET/api/catchment/compute-defaultsreadCatchment-wide compute defaults.
GET/api/catchment/instance-typesfullMachine types available on the Catchment's cloud: EC2 instance types, Azure VM sizes or Compute Engine machine types.
POST/api/catchment/cloud/verifyfullCheck the cloud configuration.
POST/api/catchment/keys/rotatefullReplace API keys.
POST/api/catchment/resetfullReset every Pond.
GET/api/catchment/usagefullSize of the state directory.
GET/api/catchment/archivefullDownload the state directory as a tar stream.
GET/api/catchment/recordsreadWhere Apps' Records live, and the managed PostgreSQL's state.
PUT/api/catchment/recordsfullChange it. Body: any of target, memory, listen, host, tls_cert, tls_key.
GET/api/catchment/records/readerfullA read-only connection URL for a client on another machine.
GET/api/catchment/mediareadWhere Apps' Media lives.
PUT/api/catchment/mediafullChange it. Body: target.
POST/api/catchment/records/movefullMove Records. Body: target, postgres_version, confirm (the Catchment's name). Runs in the background.
POST/api/catchment/media/movefullMove Media. Body: target, confirm.
GET/api/catchment/movereadA move's progress: state (ending done or failed), detail, error.

Deploying and removing​

MethodPathLevelDescription
POST/api/deployfullDeploy a Pond (a packaged upload or a git reference). Redeploying the version a line runs is a 409 unless force is set or the Pond is an App. A Puddle of the line is a 409 unless replace_puddle is set.
GET/api/ponds/{name}/versions/{version}readWhether a version is deployed.
DELETE/api/ponds/{name}fullRemove a major line.

Status and history​

MethodPathLevelDescription
GET/api/statusreadEvery Pond's state, freshness, recurring Refreshes and failures, the edges between Ponds, and the caller's access level.
GET/api/runsreadRun history, newest first. Parameters: pond, lineage (include upstream Ponds), ripples (include Ripple Runs), limit (up to 1000).
GET/api/viewreadThe Pond graph, including Ponds in upstream Catchments reached through ducts.
GET/api/lineagereadObserved table lineage. Parameters: pond, major, table, columns.
GET/api/ponds/{name}/tracereadThe run that produced some rows. Parameters: table, where.
GET/api/ponds/{name}/freshnessread, TapHow fresh the Pond's data is: freshness (the point in time it reflects), changed (when its output last changed), refreshing, and when each table and Object last changed. Read-level keys see exposed tables only; a Tap's key, its own Pond's, without Objects.
GET/api/ponds/{name}/reportsreadThe Pond's Run reports from pond.report(): its own, newest Run first (limit, default 50); with f, that Run's own report and the upstream reports it read.

Refreshes and windows​

MethodPathLevelDescription
POST/api/ponds/{name}/refreshdemandRefresh now. Parameters (at most one): at, an ISO freshness to ask for instead of now; fresh_within_ms, to ask for data no older than this. Refused (422) when it reaches a Puddle. (Before Refresh, this route marked a Pond for a rebuild; that is now /rebuild.)
GET/api/ponds/{name}/refreshesreadList the recurring Refreshes, with when each next asks.
POST/api/ponds/{name}/refreshesdemandAdd a recurring Refresh. Body: every_seconds (0 is continuous), continuous, start, days, until, name.
POST/api/ponds/{name}/refreshes/{refresh_name}/removedemandRemove a recurring Refresh.
GET/api/puddlesreadThe Puddles on this Catchment.
POST/api/puddlesfullDeploy Puddles. Multipart: bundle (a Pond project, zipped) and spec (JSON: sources, set, live, as_at, origin with name, url and headers, and force). A Puddle already there is a 409 listing them in detail.replace, unless force.
POST/api/ponds/{name}/puddles/hydratefullBuild the Puddles the Pond reaches again and run from the new baseline. Body: as_at, and origin to read another Catchment.
POST/api/ponds/{name}/puddles/rewindfullGo back to the Puddle baseline and run from it.
POST/api/ponds/{name}/puddles/refreshdemandMove the Puddles to a target and refresh at it. Body: target (next-change, next-run or most-recent) or to.
GET/api/ponds/{name}/windowsreadList windows.
POST/api/ponds/{name}/windowsfullAdd a window.
POST/api/ponds/{name}/windows/{window_name}/removefullRemove a window.

Control​

MethodPathLevelDescription
POST/api/ponds/{name}/wakefullWake.
POST/api/ponds/{name}/forcefullForce.
POST/api/ponds/{name}/rebuildfullMark for a rebuild on the next run. Parameter: clear.
POST/api/repairfullRepair a connected set of Ponds.
POST/api/ponds/{name}/sleepfullSleep.
POST/api/ponds/{name}/killfullKill.
POST/api/ponds/{name}/clearfullClear a failure.
POST/api/ponds/{name}/resetfullReset to the freshly deployed state.
POST/api/ponds/{name}/reset-contractfullForget the recorded output schema.
POST/api/ponds/{name}/wipe-historyfullDelete run history.
POST/api/ponds/batchfullApply operations to many Ponds, as the web UI's Pond Actions do.
GET/api/ponds/{name}/budgetreadRetry budgets.
POST/api/ponds/{name}/budgetfullSet retry budgets.
GET/api/ponds/{name}/duckreadEffective compute settings.
POST/api/ponds/{name}/duckfullSet or clear the compute override.

Data​

MethodPathLevelDescription
POST/api/queryread, TapRun SQL against one Pond's tables. Body: pond, sql, optional major, version, format (json, csv or parquet), at and since (ISO 8601 times, as duckstring query --at; not with a Tap's key). With a Tap's key, pond can be left out. A warning about the read comes back in an X-Duckstring-Warning header.
GET/api/ponds/{name}/changesreadThe times a Pond line's published tables changed, oldest first, as far back as it keeps. Query: optional major, version, after, upto (ISO 8601).
POST/api/query/page, /api/query/count, /api/query/historyreadPaged reads used by the web UI's data viewer. A page or count may carry a query_id.
POST/api/query/cancelreadStop the data viewer's query query_id: interrupt it where it runs, and refuse it if it hasn't started yet.
GET/api/ponds/{name}/tables/{table}/runsreadThe run freshnesses of a Trickle table, used by the data viewer's window selector.
GET/api/ponds/{name}/tablesreadList published tables.
GET/api/ponds/{name}/ripples/{table}readDownload a table's published files as a zip.
DELETE/api/ponds/{name}/tables/{table}fullDelete a table.
GET/api/ponds/{name}/objectsreadList Objects.
GET/api/ponds/{name}/objects/{obj}readDownload an Object.
DELETE/api/ponds/{name}/objects/{obj}fullDelete an Object.

Catalog​

MethodPathLevelDescription
GET/api/serveread, TapServed majors and exposed tables. A Tap's key sees its own Pond.
POST/api/serve/queryread, TapRun SQL across the catalog. Read-level keys see only exposed tables; a Tap's key, only its own Pond's.
POST/api/ponds/{name}/serve/promotefullChange the served major.
POST/api/ponds/{name}/serve/exposefullExpose or hide a table.

Spouts​

MethodPathLevelDescription
GET/api/ponds/{name}/spoutsfullList Spouts.
POST/api/ponds/{name}/spoutsfullAdd a Spout.
POST/api/ponds/{name}/spouts/testfullTest a destination without writing data.
POST/api/ponds/{name}/spouts/{spout}/removefullRemove a Spout.
POST/api/ponds/{name}/spouts/{spout}/{action}fullwake, force, sleep, kill, clear or resync.

Taps​

MethodPathLevelDescription
GET/api/ponds/{name}/tapsfullList Taps, with their counts. Never keys.
POST/api/ponds/{name}/tapsfullAdd a Tap. Body: name, optional fresh_within_ms. The response holds the key, once.
POST/api/ponds/{name}/taps/{tap}/rotatefullA new key for a Tap, returned once.
POST/api/ponds/{name}/taps/{tap}/removefullRemove a Tap.

Apps​

MethodPathLevelDescription
GET/api/ponds/{name}/app/instancesreadAn App's recent instances, newest first. limit (default 20).
GET/api/ponds/{name}/app/logsfullAn instance's output as text. instance (default the newest), tail (bytes from the end, default 65536) or offset (bytes from there on). The x-log-offset header is where the next read starts.
POST/api/ponds/{name}/app/restartfullStop an App's instances and start a fresh one, clearing a failure or a Kill first. Returns once the restart has begun.
GET/api/ponds/{name}/app/scalereadScaling settings and where each comes from, running instances, and recent decisions.
POST/api/ponds/{name}/app/scalefullOverride settings or set the count, as app scale. Body: any of min_instances, max_instances, concurrency, connections, requests, cpu, memory, load, to, hold_s, release, clear.
POST/api/ponds/{name}/app/instances/{instance}/drainfullSend no new sessions to an instance; it stops once its work is done.
POST/api/ponds/{name}/app/migratefullMigrate a trial major again from the live one. major names the trial.
GET/api/app-datareadEvery App line holding Records or Media: its state, Records tables, and Media file count and size.
GET/api/app-data/{name}/{major}/mediareadA line's Media files. prefix narrows to a folder.
GET/api/app-data/{name}/{major}/media/filereadDownload a file. path names it.
POST/api/app-data/{name}/{major}/media/filefullUpload a file to path, as the request body or a multipart file, replacing one there. Refused on a retired line.
DELETE/api/app-data/{name}/{major}/media/filefullDelete the file at path. Refused on a retired line.
POST/api/app-data/{name}/{major}/purgefullDelete a line's Records and Media for good. Body: confirm (the Catchment's name).

Requests to an App itself go to /apps/{name}/v{major}/... on the Catchment's port, outside /api; see [app]. A Tap added to an App has no key ("key": null): requests to the App run it.

Secrets and alerts​

MethodPathLevelDescription
GET/api/secretsfullSecret names and when each was set. Never values.
POST/api/secretsfullSet a secret. Body: name, value.
DELETE/api/secrets/{name}fullDelete a secret.
GET/api/alertsfullList channels.
POST/api/alertsfullAdd a channel.
DELETE/api/alerts/{name}fullRemove a channel.
POST/api/alerts/{name}/testfullSend a test message.
GET/api/alerts/deliveriesfullRecent deliveries.

Ducts​

MethodPathLevelDescription
GET/api/ductfullList ducts.
POST/api/ductfullCreate a duct.
DELETE/api/duct/{origin}fullDestroy a duct.
POST/api/duct/{origin}/pondsfullDraw a Pond.
DELETE/api/duct/{origin}/ponds/{pond}fullStop drawing a Pond.
POST/api/duct/{origin}/syncfullDraw every exposed Pond.
POST/api/ponds/{name}/openfullOpen a Pond to demand from other Catchments.
POST/api/ponds/{name}/closefullClose it.

The /api/draw/* routes that ducts use to transfer data, and the /api/duck/* and /api/pool/* routes that Ducks use to talk to the Catchment, are internal and not covered here.

Metrics​

GET /metrics serves Prometheus metrics without authentication, following exporter convention. Restrict network access to it if Pond names are sensitive.

MetricTypeDescription
duckstring_upgauge1 while the Catchment is serving.
duckstring_pond_freshness_lag_secondsgaugeSeconds since each Pond's freshness.
duckstring_pond_failed, duckstring_pond_blocked, duckstring_pond_killedgauge1 when the Pond is in that state.
duckstring_pond_runs_completed_totalcounterCompleted Pond Runs.
duckstring_pond_failures_totalcounterFailed Pond Runs.
duckstring_pond_run_seconds_totalcounterTotal Duck execution time, summed over Ripple Runs.
duckstring_pond_duck_targetgauge1 for the compute target each Pond runs on.
duckstring_pond_flockgauge1 for each Pond's effective Flock mode and engine.
duckstring_spout_delivery_lag_secondsgaugeSeconds since each Spout last delivered.
duckstring_spout_failedgauge1 when the Spout's latest delivery failed.
duckstring_alert_deliveries_totalcounterAlert deliveries, by status.
duckstring_flock_dispatched_totalcounterComputations sent to the Flock, per Pond.
duckstring_flock_dispatch_failures_totalcounterFlock dispatches that failed and ran in the Duck instead. The only sign that a Flock is misconfigured.
duckstring_app_instancesgaugeRunning instances of each App, labelled place (catchment or elsewhere).
duckstring_app_activegaugeActive requests and WebSockets across an App's instances.
duckstring_app_cpu_share, duckstring_app_memory_sharegaugeMean CPU and memory of an App's instances, as shares of their cores and limit.
duckstring_app_reported_loadgaugeMean load an App's instances report themselves.
duckstring_app_at_maximumgauge1 while an App is held at its maximum instances under pressure.
duckstring_app_instance_starts_totalcounterApp instances started, by place.
duckstring_app_instance_stops_totalcounterApp instances stopped, by reason.
duckstring_tap_queries_totalcounterQueries through each Tap, labelled pond, major and tap.
duckstring_tap_refreshes_totalcounterRefreshes sent by each Tap's queries.

Other interfaces​

The catalog can also be queried over the Postgres wire protocol and Arrow Flight, each enabled by setting a port (DUCKSTRING_SERVE_PG_PORT, DUCKSTRING_SERVE_FLIGHT_PORT; see Environment Variables). Both use an API key as the password and apply the same access levels. A Tap's key works on both, except that a Catchment without keys never asks a Postgres client for a password, so there a connection can't be recognised as a Tap's.