Download OpenAPI specification:
OpenAPI spec for the KDB-X Database Service.
Returns the names of all tables in the database.
| assembly | string non-empty Example: assembly=marketdata-emea Assembly whose table names are returned. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
session.list_tables()
[- "forex",
- "sensor"
]Creates a table from the provided schema definition.
| table required | string Table name |
| assembly | string non-empty Example: assembly=marketdata-emea Assembly to create the table in. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
| type required | string Enum: "partitioned" "splayed" "splayed_mem" "basic" The table type. |
| tableType | string Enum: "partitioned" "splayed" "splayed_mem" "basic" Alias for |
| prtnCol required | string Partition column to use for partitioned tables. The column chosen is your primary time filter: it is used by a query's
|
required | Array of objects (TableColumnSpec) |
| primaryKeys | Array of strings Names of columns to use as primary keys for this table. Primary keys identify unique rows. When provided, the table is keyed by these columns, and rows with matching keys update existing records. |
| blockSize | integer Default: 10000 Block size for partitioned storage writes. |
| sortColsMem | Array of strings A list of columns to use for sorting columns in a memory tier. Setting this value will sort data as it arrives in memory. |
| sortColsOrd | Array of strings A list of columns to use for sorting columns in an ordinal partitioned tier. Setting this value will sort data as it migrates into ordinal partitions. |
| sortColsDisk | Array of strings A list of columns to use for sorting columns in a normal disk tier. Settings this value will sort data as it is migrated into disk partitions. |
| description | string |
{- "type": "partitioned",
- "prtnCol": "realTime",
- "columns": [
- {
- "name": "time",
- "type": "timespan"
}, - {
- "name": "sym",
- "type": "symbol",
- "attrMem": "grouped",
- "attrDisk": "parted",
- "attrOrd": "parted"
}, - {
- "name": "realTime",
- "type": "timestamp"
}, - {
- "name": "bid",
- "type": "float"
}, - {
- "name": "ask",
- "type": "float"
}, - {
- "name": "bidSize",
- "type": "long"
}, - {
- "name": "askSize",
- "type": "long"
}
], - "blockSize": 10000,
- "sortColsOrd": [
- "sym"
], - "sortColsDisk": [
- "sym"
], - "description": "Quote data"
}{- "jobId": "d9726870-1c5c-0d13-4b90-be5fbcb2ad2f",
- "status": "completed",
- "statusUri": "/api/v0/jobs/d9726870-1c5c-0d13-4b90-be5fbcb2ad2f",
- "startedAt": "2026-03-30T13:37:44.365774085",
- "finishedAt": null,
- "table": "fxquote",
- "warnings": [ ]
}Returns the table definition (schema/columns) and associated metadata for a given table.
| table required | string Table name |
| assembly | string non-empty Example: assembly=marketdata-emea Assembly whose table definition is returned. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
session.describe_table(table="fxquote")
{- "description": "Quote data",
- "type": "partitioned",
- "blockSize": 10000,
- "prtnCol": "realTime",
- "sortColsOrd": [
- "sym"
], - "sortColsDisk": [
- "sym"
], - "columns": [
- {
- "name": "time",
- "type": "timespan"
}, - {
- "name": "sym",
- "type": "symbol",
- "attrMem": "grouped",
- "attrDisk": "parted",
- "attrOrd": "parted"
}, - {
- "name": "realTime",
- "type": "timestamp"
}, - {
- "name": "bid",
- "type": "float"
}, - {
- "name": "ask",
- "type": "float"
}, - {
- "name": "bidSize",
- "type": "long"
}, - {
- "name": "askSize",
- "type": "long"
}
], - "name": "quote"
}Drops a table and its associated data.
| table required | string Table name |
| assembly | string non-empty Example: assembly=marketdata-emea Assembly to drop the table from. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
session.drop_table(table="instruments")
{- "jobId": "c4ceac2c-664a-ce9c-aa5c-b1498f850d22",
- "status": "completed",
- "statusUri": "/api/v0/jobs/c4ceac2c-664a-ce9c-aa5c-b1498f850d22",
- "startedAt": "2026-03-31T05:36:22.900404270",
- "finishedAt": null,
- "table": "instruments",
- "warnings": [ ]
}Returns the current status of a batch ingest job.
| jobId required | string Batch ingest job identifier. |
| assembly | string non-empty Example: assembly=marketdata-emea Assembly containing the import job. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
session.get_import(job_id="3fa85f64-5717-4562-b3fc-2c963f66afa6")
{- "jobId": "26adfb1d-29bc-fab9-5e32-73f80ea51300",
- "database": "db",
- "jobType": "import",
- "status": "completed",
- "affectedTables": [
- "forex"
], - "processedPartitions": [
- "2026-02-03"
], - "progress": {
- "currentPartition": "",
- "partitionIndex": 1,
- "partitionTotal": 1,
- "currentTable": "",
- "tableIndex": 0,
- "tableTotal": 0
}, - "error": "",
- "warnings": [ ],
- "updated": "2026-03-22T13:25:44.312559923"
}Attempts to cancel a running batch ingest job.
| jobId required | string Batch ingest job identifier. |
| assembly | string non-empty Example: assembly=marketdata-emea Assembly containing the import job to cancel. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
session.cancel_import(job_id="3fa85f64-5717-4562-b3fc-2c963f66afa6")
"Ingest aborted"Submit a batch ingest job for a table using files on the server.
For CSV ingest, processing order is types (initial parse), then postparse (transform/derive), then include (final output column selection).
Returns a pending job response; ingestion continues after the response. Final success/failure is available via GET /api/v0/imports/{jobId}.
| assembly | string non-empty Example: assembly=marketdata-emea Assembly to import the files into. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
| table required | string Target table name. |
| path required | string Path to input data on the server filesystem. Accepted forms:
Glob semantics:
The service ingests all matched files. Example values:
|
| format | string Enum: "qbinary" "csv" "parquet" Input data format. If omitted, the service may auto-detect it from the file(s). |
| mode | string Default: "merge" Enum: "overwrite" "merge" Optional ingest mode. If omitted, the service uses |
| delimiter | string Default: "," Delimiter character for delimited text. Ignored for parquet and qbinary. |
| decimal | string Default: "." Decimal separator character for delimited text. Ignored for parquet and qbinary. |
| createTable | boolean Default: false If true and the table does not exist, create it prior to ingest. |
| header | Array of strings If the file has headers, this is optional. If provided, it overrides header names by position. If the file has no headers and either postparse is used or the file has unused columns, this is required (names by position). If createTable=true and the table doesn’t exist, these headers are used as the new table’s column names. |
| include | Array of strings Optional list of column names to ingest (and their order). Only these columns are kept. Applied after both headers are resolved & postparse is applied. |
| types | string Optional type string in CSV parse format (uppercase), e.g. |
object A dictionary of data transforms, made up of column names as keys and q expression strings as values. Existing columns can be modified, and new ones created. Columns from the file are available for use in the expression via a
Runs after loading and parsing (including typecasting) of data in the file is done. When ingesting into an existing table, the final output columns must be compatible with the target table schema. | |
| headerRowIndex | integer Default: 0 Header row index (0-based). Use -1 when there is no header row. |
{- "table": "quote",
- "path": "quote.csv"
}{- "jobId": "26adfb1d-29bc-fab9-5e32-73f80ea51300",
- "database": "db",
- "jobType": "import",
- "status": "pending",
- "affectedTables": [ ],
- "processedPartitions": [ ],
- "progress": {
- "currentPartition": "",
- "partitionIndex": 0,
- "partitionTotal": 0,
- "currentTable": "",
- "tableIndex": 0,
- "tableTotal": 0
}, - "error": "",
- "warnings": [ ],
- "updated": "2026-03-22T13:25:44.177025580"
}Submit a batch ingest job for a kdb-native data location readable by the service. The provided path may reference a partitioned HDB directory and may also support other kdb-native layouts such as splayed tables or basic/q-binary tables. The service returns a job ID and continues ingestion asynchronously after the response.
| assembly | string non-empty Example: assembly=marketdata-emea Assembly to import the kdb-native data into. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
| path required | string Path to a kdb-native data location readable by the service, such as a partitioned HDB directory, a parent directory containing one or more splayed tables, or a parent directory containing basic/q-binary tables. Path is resolved relative to the configured import root. |
| mode | string Default: "merge" Enum: "overwrite" "merge" Optional ingest mode. If omitted, the service uses |
| createTable | boolean Default: false If true and the target table does not exist, create it before ingest. |
{- "path": "/path/to/hdb",
- "mode": "merge",
- "createTable": false
}{- "jobId": "26adfb1d-29bc-fab9-5e32-73f80ea51300",
- "database": "db",
- "jobType": "import",
- "status": "pending",
- "affectedTables": [ ],
- "processedPartitions": [ ],
- "progress": {
- "currentPartition": "",
- "partitionIndex": 0,
- "partitionTotal": 0,
- "currentTable": "",
- "tableIndex": 0,
- "tableTotal": 0
}, - "error": "",
- "warnings": [ ],
- "updated": "2026-03-22T13:25:44.177025580"
}Insert data provided inline in the request body. Supports either a row-matrix (array of rows) or a list of JSON dictionaries (one object per row). Returns a pending job response; final success/failure is available via GET /api/v0/imports/{jobId}.
| assembly | string non-empty Example: assembly=marketdata-emea Assembly to import the inline data into. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
| table required | string Target table name. |
required | Array of any or Array of objects |
| createTable | boolean Default: false |
| mode | string Default: "merge" Enum: "overwrite" "merge" Optional ingest mode. If omitted, the service uses |
| columnNames | Array of strings |
| types | string Optional type string (case-sensitive), e.g. f=float, j=long, p=timestamp, s=symbol, C=string, *=generic list. See https://code.kx.com/q/ref/cast/ for full details. |
{- "table": "quote",
- "data": [
- [
- "2026-01-21T10:00:00.000",
- "AAPL",
- 101.1,
- 101.2
], - [
- "2026-01-21T10:00:01.000",
- "AAPL",
- 101.2,
- 101.3
]
], - "columnNames": [
- "timestamp",
- "sym",
- "bid",
- "ask"
]
}{- "jobId": "26adfb1d-29bc-fab9-5e32-73f80ea51300",
- "database": "db",
- "jobType": "import",
- "status": "pending",
- "affectedTables": [ ],
- "processedPartitions": [ ],
- "progress": {
- "currentPartition": "",
- "partitionIndex": 0,
- "partitionTotal": 0,
- "currentTable": "",
- "tableIndex": 0,
- "tableTotal": 0
}, - "error": "",
- "warnings": [ ],
- "updated": "2026-03-22T13:25:44.177025580"
}Submits a batch delete job for a table, removing the rows that match an optional time window and a filter. The job is asynchronous: the 202 carries a pending job response, deletion continues after it, and the final outcome is read from GET /api/v0/deletes/{jobId}.
Rows are removed from the on-disk partitions and from the in-memory tiers, so a window reaching into the interval currently being ingested is accepted. The delete is bounded by the position in the stream at which it executes: rows arriving after that point are kept, even where they fall inside the requested window. In-memory rows go as each database process applies the delete, shortly after the job is accepted, so a query issued immediately afterwards may still return them.
Rows already moved to an object storage tier cannot be deleted. A startTS on or before the object storage watermark is rejected with a 400; raise startTS so that the window begins after the data held in object storage.
For a table that is not partitioned, startTS and endTS are ignored and filter alone selects the rows to delete.
| assembly | string non-empty Example: assembly=marketdata-emea Assembly to delete rows from. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
| table required | string Table to delete rows from. |
| startTS | string Inclusive start of the deletion window. Defaults to the beginning of time. Same formats as query startTS. Must begin after any data held in an object storage tier - a window overlapping object storage is rejected. Ignored for a table that is not partitioned. |
| endTS | string Exclusive end of the deletion window. Defaults to the end of time. May reach into the interval currently being ingested: rows already ingested are deleted from the in-memory tiers, and rows arriving after the delete executes are kept. Ignored for a table that is not partitioned. |
| filter required | Array of any List of filter triples, same syntax as the structured-query filter. An explicit empty list ([]) deletes all rows in the time window, and is mandatory as a safety catch even when no filtering is desired. |
{- "table": "trade",
- "startTS": "2026.04.03D00:00:00.000000000",
- "endTS": "2026.04.04D00:00:00.000000000",
- "filter": [
- [
- "=",
- "sym",
- "AAPL"
]
]
}{- "jobId": "54f5cf87-dbc2-4336-d109-173ed56c0b86",
- "database": "db",
- "jobType": "delete",
- "status": "pending",
- "affectedTables": [ ],
- "processedPartitions": [ ],
- "progress": {
- "currentPartition": "",
- "partitionIndex": 0,
- "partitionTotal": 0,
- "currentTable": "",
- "tableIndex": 0,
- "tableTotal": 0
}, - "error": "",
- "warnings": [ ],
- "updated": "2026-08-18T13:25:44.177025580"
}Returns the current status of a batch delete job.
| jobId required | string Batch delete job identifier. |
| assembly | string non-empty Example: assembly=marketdata-emea Assembly containing the delete job. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
session.get_delete(job_id="54f5cf87-dbc2-4336-d109-173ed56c0b86")
{- "jobId": "54f5cf87-dbc2-4336-d109-173ed56c0b86",
- "database": "db",
- "jobType": "delete",
- "status": "completed",
- "affectedTables": [
- "trade"
], - "processedPartitions": [
- "2026-04-03"
], - "progress": {
- "currentPartition": "",
- "partitionIndex": 1,
- "partitionTotal": 1,
- "currentTable": "",
- "tableIndex": 0,
- "tableTotal": 0
}, - "error": "",
- "warnings": [ ],
- "updated": "2026-08-18T13:47:27.461244645"
}Clears a batch delete job's tracked status, so that the job no longer appears in GET /api/v0/deletes/{jobId}. This does not abort or roll back an in-flight delete: once submitted, a delete always runs to completion.
| jobId required | string Batch delete job identifier. |
| assembly | string non-empty Example: assembly=marketdata-emea Assembly containing the delete job to clear. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
session.cancel_delete(job_id="54f5cf87-dbc2-4336-d109-173ed56c0b86")
""Structured query using explicit parameters (table, time range, filters, aggregations) rather than a free-form query string.
| table required | string Table name |
| startTS | string Inclusive start of timestamp range |
| endTS | string Exclusive end of timestamp range |
| inputTZ | string Timezones should be supplied in tz database format, for example |
| outputTZ | string Timezones should be supplied in tz database format, for example |
| outputTZCols | Array of strings[ items ] Columns that should be converted to 'outputTZ' |
Array of strings or Array of arrays The
It is also possible to nest filters with the logical operators
Supported filter operators are | |
| groupBy | Array of strings A list of column names to group by |
| agg | Array of strings[ items ]
Available aggregation functions are: all, any, avg, cor, count, cov, dev, distinct, first, last, max, min, prd, scov, sdev, sum, svar, var, wavg, wsum. Note: distinct always returns a list. |
| fill | string
|
| temporality | string Temporality controls how the query interprets the time range between Supported values are:
|
| sortCols | Array of strings Columns to be sorted, post query execution |
| limit | Array of integers Limit of rows to return |
object (ScopeObject) Query routing selector. | |
object (LabelsObject) User-defined assembly labels to target. |
{- "table": "quote",
- "startTS": "2024.11.02T00:00:00.000",
- "endTS": "2024.11.03T00:00:00.000",
- "inputTZ": "UTC",
- "outputTZ": "UTC",
- "outputTZCols": [
- [
- "createTS",
- "updateTS"
]
], - "filter": [
- [
- "or",
- [
- "=",
- "sym",
- "DNDF.CAN"
], - [
- ">",
- "price",
- "300.50"
]
]
], - "groupBy": [
- "sym"
], - "agg": [
- [
- "minPx",
- "min",
- "price"
]
], - "fill": "zero",
- "temporality": "slice",
- "sortCols": [
- "sym",
- "desc"
], - "limit": [
- 3
], - "scope": {
- "assembly": "marketdata-emea"
}, - "labels": {
- "region": "emea",
- "assetClass": "fx"
}
}{- "header": {
- "corr": "f98f13f8-621b-4721-b242-3afb94077441",
- "logCorr": "f98f13f8-621b-4721-b242-3afb94077441",
- "rcvTS": "2026-01-22T07:36:33.459000000",
- "http": "json",
- "api": "simple",
- "agg": ":192.168.240.7:5060",
- "refVintage": -9223372036854776000,
- "rc": 0,
- "ac": 0,
- "ai": "",
- "limitApplied": false
}, - "payload": [
- {
- "time": "0D07:33:41.240573052",
- "sym": "X",
- "realTime": "2026-01-24T07:33:41.240473052",
- "ask": 2.975187,
- "asize": 14,
- "bid": 45.16773,
- "bsize": 36,
- "sensorID": 0,
- "randomID": 14
}, - {
- "time": "0D07:33:41.240573118",
- "sym": "K",
- "realTime": "2026-01-24T07:33:41.240473118",
- "ask": 36.78192,
- "asize": 27,
- "bid": 61.92058,
- "bsize": 28,
- "sensorID": 0,
- "randomID": 0
}
]
}Lightweight data retrieval that fetches a small sample of a table using minimal time and resources, for reviewing data or testing software compatibility with a schema.
Returns up to limit rows from the table and time range. It is guaranteed to search all available data for results: if fewer than limit rows are returned, they contain all the available data. Beyond this there are no guarantees as to which particular rows are returned.
| table required | string Table name |
| startTS | string Inclusive start of timestamp range. Optional; defaults to the full temporal range of the database. The timestamp must be midnight so the date range covers full days. |
| endTS | string Exclusive end of timestamp range. Optional; defaults to the full temporal range of the database. The timestamp must be midnight so the date range covers full days. |
| limit | integer Maximum number of rows to return. Defaults to 1000. |
object (ScopeObject) Query routing selector. | |
object (LabelsObject) User-defined assembly labels to target. |
{- "table": "quote",
- "startTS": "2024.11.02T00:00:00.000",
- "endTS": "2024.11.03T00:00:00.000",
- "limit": 500,
- "scope": {
- "assembly": "marketdata-emea"
}, - "labels": {
- "region": "emea",
- "assetClass": "fx"
}
}{- "header": {
- "corr": "f98f13f8-621b-4721-b242-3afb94077441",
- "logCorr": "f98f13f8-621b-4721-b242-3afb94077441",
- "rcvTS": "2026-01-22T07:36:33.459000000",
- "http": "json",
- "api": "preview",
- "agg": ":192.168.240.7:5060",
- "refVintage": -9223372036854776000,
- "rc": 0,
- "ac": 0,
- "ai": "",
- "limitApplied": true
}, - "payload": [
- {
- "time": "0D07:33:41.240573052",
- "sym": "X",
- "realTime": "2026-01-24T07:33:41.240473052",
- "ask": 2.975187,
- "asize": 14,
- "bid": 45.16773,
- "bsize": 36,
- "sensorID": 0,
- "randomID": 14
}, - {
- "time": "0D07:33:41.240573118",
- "sym": "K",
- "realTime": "2026-01-24T07:33:41.240473118",
- "ask": 36.78192,
- "asize": 27,
- "bid": 61.92058,
- "bsize": 28,
- "sensorID": 0,
- "randomID": 0
}
]
}Executes a SQL query string (SELECT-only) against the database.
| query required | string SQL expression. Must be a |
object (ScopeObject) Query routing selector. |
{- "query": "select sym, bid, ask from quote where bid > 100 by sym",
- "scope": {
- "assembly": "marketdata-emea"
}
}{- "header": {
- "corr": "f98f13f8-621b-4721-b242-3afb94077441",
- "logCorr": "f98f13f8-621b-4721-b242-3afb94077441",
- "rcvTS": "2026-01-22T07:36:33.459000000",
- "http": "json",
- "api": "sql",
- "agg": ":192.168.240.7:5060",
- "refVintage": -9223372036854776000,
- "rc": 0,
- "ac": 0,
- "ai": "",
- "limitApplied": false
}, - "payload": [
- {
- "sym": "X",
- "bid": 45.16773,
- "ask": 2.975187
}, - {
- "sym": "K",
- "bid": 61.92058,
- "ask": 36.78192
}
]
}Executes a q query string against the database.
| query required | string Freeform q query |
| agg | string The gateway concatenates query results from each tier (RDB, IDB, HDB) by performing a
|
object (ScopeObject) Query routing selector. | |
object (LabelsObject) User-defined assembly labels to target. |
{- "query": "select from quote where sym=`DNDF.CAN, price>300.5",
- "agg": "{select minPx:min price by sym from x}",
- "scope": {
- "assembly": "marketdata-emea"
}, - "labels": {
- "region": "emea",
- "assetClass": "fx"
}
}{- "header": {
- "corr": "f98f13f8-621b-4721-b242-3afb94077441",
- "logCorr": "f98f13f8-621b-4721-b242-3afb94077441",
- "rcvTS": "2026-01-22T07:36:33.459000000",
- "http": "json",
- "api": "qsql",
- "agg": ":192.168.240.7:5060",
- "refVintage": -9223372036854776000,
- "rc": 0,
- "ac": 0,
- "ai": "",
- "limitApplied": false
}, - "payload": [
- {
- "sym": "X",
- "bid": 45.16773
}, - {
- "sym": "K",
- "bid": 61.92058
}
]
}Exports the active assembly configuration for a DB Service deployment as YAML.
The assembly is the database configuration document used by DB Service. It defines the assembly name, labels, table schemas, stream bus settings, storage mounts, and service elements such as Storage Manager tiers and DAP mounts.
The response body is the YAML document itself, not a JSON wrapper.
| assembly | string non-empty Example: assembly=marketdata-emea Name of the assembly configuration to export. Required when DB Service is configured with more than one assembly; optional when exactly one assembly is configured. |
assembly_yaml = session.export_assembly() print(assembly_yaml)
{ "name": "Test assembly", "description": "Test assembly", "labels": { "region": "NAM" }, "bus": { "messages": { "protocol": "rt", "topic": "dataStream" }, "stream": { "protocol": "custom", "topic": "dataStream", "nodes": [ "tick:5010" ] } }, "mounts": { "rdb": { "type": "stream", "baseURI": "none", "partition": "none" }, "idb": { "type": "local", "baseURI": "file:///shared/data/db/idb", "partition": "ordinal" }, "hdb": { "type": "local", "baseURI": "file:///shared/data/db/hdb", "partition": "date" } }, "tables": { "fxquote": { "description": "FX quote data", "type": "partitioned", "blockSize": 10000, "prtnCol": "ts", "sortColsMem": [ "sym" ], "sortColsOrd": [ "sym" ], "sortColsDisk": [ "sym" ], "columns": [ { "name": "trddate", "description": "Trade date", "type": "date" }, { "name": "ts", "description": "Quote timestamp", "type": "timestamp" }, { "name": "sym", "description": "Symbol name", "type": "symbol", "attrMem": "grouped", "attrOrd": "parted", "attrDisk": "parted" }, { "name": "bid", "description": "Bid price", "type": "float" }, { "name": "ask", "description": "Ask price", "type": "float" } ] } }, "elements": { "sm": { "source": "stream", "tiers": [ { "name": "stream", "mount": "rdb" }, { "name": "idb", "mount": "idb", "schedule": { "freq": "0D00:10:00" } }, { "name": "hdb1", "mount": "hdb", "schedule": { "freq": "1D00:00:00", "snap": "01:35:00" }, "retain": { "time": "2 days" }, "compression": { "algorithm": "gzip", "block": 17, "level": 9 } } ], "enforceSchema": false, "chunkSize": 500000, "sortLimitGB": 1, "waitTm": 250, "eodPeachLevel": [ "table" ], "disableDiscovery": true } } }