KDB knowledge

6. Web console

What you will learn

Start the server

kdb serve market --backups backups
KDB 0.2.0-dev
  console   http://127.0.0.1:9900
  postgres  127.0.0.1:8832 (PostgreSQL protocol, no TLS; no password on this computer only)
  data      market
  backups   backups
  access    no token
  commits   synced to disk before they are confirmed (--sync-commits always)
  limits    statement timeout 1 min, result memory 1.00 GB, 5000000 groups, 32 statements per user
  safety    writes allowed; DROP TABLE kept 7 days (UNDROP TABLE); audit log off
  recovery  manifest copy: b, last shutdown: clean

Press Ctrl+C to stop.

Then open http://127.0.0.1:9900 in Chrome, Edge or Firefox. While the server runs, it prints one line per request, for example 2026-09-11 14:07:33 GET /health 200 0 ms.

kdb serve market serves one database folder (here the folder market). To serve every database in the data folder (chapter 1), start it without a folder:

kdb serve --backups backups
KDB 0.2.0-dev
  console   http://127.0.0.1:9900
  postgres  127.0.0.1:8832 (PostgreSQL protocol, no TLS; no password on this computer only)
  data      D:/AMP/TechnivsProject/01_NChartPro/KDB/build/bin/data (from program folder; one folder per database)
  default   default (used when a request names no database)
  backups   backups/<database name>
  access    no token
  commits   synced to disk before they are confirmed (--sync-commits always)
  limits    statement timeout 1 min, result memory 1.00 GB, 5000000 groups, 32 statements per user
  safety    writes allowed; DROP TABLE kept 7 days (UNDROP TABLE); audit log on (SHOW AUDIT)
  recovery  the default database is created when it is first used

Press Ctrl+C to stop.

Then the console can switch between databases and create new ones (see Databases below). Each database backs up into its own sub-folder of the backup folder, so backups never mix.

OptionMeaningDefault
--data-dir FOLDERThe data folder to serve (without a database folder argument)KDB_DATA_DIR, else data next to kdb.exe
--db NAMEThe database used when a request names none. In the data folder it is created when first used.default (or the name you gave)
--port NTCP port9900
--bind ADDRESSWhich network address to listen on. 127.0.0.1 = this computer only. 0.0.0.0 = all networks.127.0.0.1
--backups FOLDERBackup folder. Needed for the Backup now button and BACKUP DATABASE. Also used by repairs.not set
--token SECRETEvery request needs this token (see below).no token
--memory MBMemory for table data kept loaded. Data over this is read from disk again when needed, which is slower. On a PC or VPS with years of market history (about 1.5 GB on disk), --memory 4096 keeps queries fast.512

To check from PowerShell that the page is there:

$page = Invoke-WebRequest http://127.0.0.1:9900/ -UseBasicParsing
"HTTP $($page.StatusCode), $($page.Headers['Content-Type'])"
if ($page.Content -match '<title>(.*?)</title>') { "title: $($Matches[1])" }
HTTP 200, text/html; charset=utf-8
title: KDB console

The console needs no internet. Its files are plain files in the folder web next to kdb (in a source checkout: web/console). Chapter 1 lists where KDB looks. A new console needs only the files copied, not a new program. When KDB finds no console files, the page says so and lists the folders it looked in.

The screen

+-------------------------------------------------------------------------------------------+
| KDB [Home v]  Database [market v] New database   market v0.2.0-dev  * Connected  Help      |  <- top bar
+-----------------------+----------------------------------------------------------+--------+
| OBJECTS       Refresh | [Run Ctrl+Enter] [Run all Ctrl+Shift+Enter] [History]  Rows | Monitor|
| [Tables 6][Views][Trig]|  1  SELECT time, open, high, low, close, volume          | Health |  <- right side
| [Procs][Funcs][Timers] |  2  FROM ochl_day WHERE symbol = 'CITY';                | Samples|
|  > brokers     REL    | Error  line 2, column 8  unknown column ...               | Databa.|
|  > ochl_day    TS     |========================= (drag) ============================| Tools  |
|  ...                  | [1 SELECT time, ...] [2 Error]                           | ------ |
|  > Indexes            | [Grid][Chart]  message                      [Export CSV] |Terminal|
|                       |  #  time                      open   high ...            |        |
|                       |========================= (drag) ============================|        |
|                       | TERMINAL [All][Queries][Writes][Timers][Errors]  Pause Clear x|        |
|                       | 14:19:02.114 HTTP 127.0.0.1  market  3 ms  2 rows  SELECT ... |        |
+-----------------------+----------------------------------------------------------+--------+
| 19 rows | parse 0.05 ms  execute 0.34 ms  round trip 12 ms           Server 2026-09-11 14:19 |  <- status bar
+-------------------------------------------------------------------------------------------+

The lines between the editor, the results and the terminal can be dragged. The console remembers the sizes.

Top bar

PartWhat it shows
Home menuThe pages: Home (this page: editor, grid, chart), Dashboard (many charts on one page, chapter 20), View data (browse tables and change rows with forms), Keep data (how long each table keeps its rows), Settings (where the data is kept, and who may log in). The button shows where you are, for example Home / Dashboard.
Database listThe database everything on the page uses: editor, object lists, health, timers, backups. See Databases.
New databaseCreates a database in the server's data folder. Only shown when the server serves a data folder.
Folder name, versionThe folder of the chosen database, and the KDB version
User and Log outOnly when the data folder has users (see Login)
Connection dotConnected, Offline (the server does not answer), Token required or Login required
HelpThe help pages, the tutorial, keyboard shortcuts. Press F1 on a word in the editor to open its help page.
Light / Dark buttonChanges the colors. The browser remembers your choice.

Right side: Monitor, Health, Samples, Databases, Tools, Terminal

The buttons down the right side open a panel over the page. The same button closes it again; so do the x** and Esc. The **pin keeps a panel open beside the page. Drag its left edge to make it wider.

ButtonThe panel
MonitorMemory, processor, caches and the statements running now. Cancel stops a statement that was sent with a request id (chapter 8).
HealthDamaged files, backups, Check now and Backup now (Health). The button gets a red dot while a file is damaged.
SamplesReady statements with Insert and Run. It opens by itself on your first visit.
DatabasesEvery database with its tables, size and folder. Click one to use it. New database and Delete.
ToolsPurge trash frees disk space in the whole data folder. Delete all data empties every table of the chosen database, after you type its name.
TerminalNot a panel: shows or hides the terminal at the bottom of Home.

Terminal

The terminal under the results is a live log of what the server does: every statement, write, timer run, login and backup, from the console, from programs over HTTP, and from the PostgreSQL port.

Databases

The list comes from GET /api/databases:

$d = Invoke-RestMethod http://127.0.0.1:9900/api/databases
"default: $($d.default)   can_create: $($d.can_create)"
$d.databases | Select-Object name, tables, default | Format-Table -AutoSize
default: market  can_create: False

name  tables default
----  ------ -------
market     6    True

Objects (left side)

The left side has one tab for each kind of object: Tables, Views, Triggers, Procedures, Functions and Timers. Each tab shows how many there are. Indexes are in the Tables tab, under the tables.

In the Tables tab:

Editor

Keyboard shortcuts

KeysWhat it does
Ctrl+EnterRun the statement under the cursor. If you selected text, run only the selection.
Ctrl+Shift+EnterRun everything in the editor
TabInsert two spaces
EscapeClose the History list, or the open panel
F1Open the help page of the word under the cursor
Ctrl+C (in the grid)Copy the selected cell
MacUse Cmd instead of Ctrl

Running statements

History

History lists the last 50 statements you ran, newest first, with the time. Click one to put it back into the editor. The history is kept in this browser only.

Grid

The grid shows the rows of a result.

Chart

Click Chart above the result. The chart button works when the result has a number column. KDB picks the chart from the columns, for example:

Change the chart with the chart type list above the chart: line, area, bars, pie, donut, treemap, heatmaps, histogram, box plot, scatter, gauge, table and more. Columns chooses the columns, Indicators adds SMA, EMA, Bollinger, RSI, MACD or stochastic. Chapter 20 explains every chart type and the dashboards.

If the result has a SYMBOL or STRING column with more than one value (for example many symbols), a symbol list appears. The chart shows one symbol at a time (lines with up to 8 symbols get one line per symbol).

ActionWhat it does
Mouse wheelZoom in and out around the mouse
Drag (hold the left button)Move left and right
Double-clickReset the view (candles: the last 200 bars)
Move the mouseCrosshair. The top line shows date, O, H, L, C, change % and volume of that candle. The price and the date are marked on the axes.
Click a name in the legendHide or show that line
Arrow keys, +, -, Home (click the chart or press Tab first)Move from candle to candle, zoom, reset

Export CSV

Export CSV downloads all rows of the result as a CSV file. It runs the statement again on the server (up to 1,000,000 rows), so it is only offered for SELECT, SHOW and EXPLAIN. The file name comes from the table name, for example ochl_day.csv. Times are UTC in ISO format.

Health panel

LineMeaning
OK - no damaged files (green) / DAMAGED (n) (red)Damaged files that KDB knows about, with their names
Last backupHow long ago (just now, 3 h ago), never, or no backup folder
DataSize of the data files and how many
Log LSNNumber of the last change in the log. It grows with every change.
OpenedWhen the server opened the database
Recovery at openWhat KDB did when it opened the database. It opens by itself if there was a problem.
Check nowReads every block of every file and the log. Example message: OK: 11 files (76.1 KB) and 1 log segments read in 1.50 ms. No damage.
Backup nowMakes a verified backup into the --backups folder. Example message: Backup 20260911-083519-806 created and verified: 9 files, 222.3 KB. The button is off when the server has no backup folder.

If Check now finds damage, stop the server and run kdb repair (chapter 9).

Status bar (bottom)

Login (users)

When the data folder has users (chapter 16), the console shows Log in instead of the token box. Type the user name and password. After the login the top bar shows the user and role, for example boss (admin), and a Log out button. The top bar dot says Login required while nobody is logged in.

Access token

Start the server with a token:

kdb serve market --token change-me-please

Choose a long random token, for example:

[Convert]::ToBase64String((1..24 | ForEach-Object { Get-Random -Maximum 256 }) -as [byte[]])

Security notes

SituationWhat to do
Only you, on this PCDefault (--bind 127.0.0.1, no token) is fine.
Other PCs in the office must connect--bind 0.0.0.0 --token <long secret>. Open the port only in the Windows firewall for your office network.
Access over the internetDo not open port 9900 to the internet. Put a reverse proxy with HTTPS (for example nginx or Caddy) in front, keep --bind 127.0.0.1, and use --token.

What KDB does to protect you:

Try it yourself

  1. Start the server with a backup folder. Make a backup with the button. Open the Health panel on the right.
  2. Run the weekly candle query from chapter 5 for VOLT and look at it as a chart. Zoom in, then double-click.
  3. Run SELECT clsoe FROM ochl_day; on line 3 of the editor. Which position does the error bar show?
Answers
  1. kdb serve market --backups backups, then Backup now. "Last backup" changes to just now.
  2. SELECT time, first(open) AS open, max(high) AS high, min(low) AS low, last(close) AS close, sum(volume) AS volume
    FROM ochl_day WHERE symbol = 'VOLT' SAMPLE BY 1w WEEK START SUNDAY;

    Then click Chart.

  3. line 3, column 8. The console counts lines in your editor, not in the statement.

Next: 7. Command line and scripts