Add a data source
You build toyfeed, a keyless data source in Python that serves its own product, toyfeed.levels, and read it from the wire as any other product. You need a checkout built from source, whose make setup lays Taji's Python in .python: it runs the plugin and, holding pyarrow, decodes the answer.
A data source is a process plugin whose manifest has a [[sources]] row: each read it lists is a product, an instrument class and a span (history, live or now) it answers. Python is the SDK that serves one (packages/taji-py/src/taji/__init__.py); taji plugin new scaffolds a Rust feature, which computes its product from Taji's own data instead.
1. Declare the source and its product
Make a directory named for the plugin's id and write its manifest:
id = "toyfeed"
name = "Toy feed"
version = "0.1.0"
taji = ">=0.7, <0.8"
[process]
run = ["toyfeed.py"]
python = {}
[[sources]]
id = "toyfeed"
reads = [{ class = "index", product = "toyfeed.levels", span = "history" }]
[[products]]
name = "levels"
description = "Levels."
columns = [
{ name = "ts_utc", type = "int" },
{ name = "price", type = "decimal" },
{ name = "size", type = "float", nullable = true },
]
[process]runstoyfeed.pyon Taji's own interpreter;python = {}gives it the standard library and thetajiSDK, nothing else.[[sources]]says what it answers:toyfeed.levelsof the classindex, athistory. Itsidis the provider id a read pins withprovider=toyfeed.[[products]]declareslevels, the producttoyfeed.levels, and its columns. A product a source reads athistorydeclarests_utc, a non-nullableintof epoch seconds.
A source may serve a core product instead (index_daily, bars, quotes, depth, chains, trades, earnings, each at the spans the plugins overview lists); plugins/pyfeed/pyfeed.py serves them. Every field: the manifest reference.
2. Answer the read
Write the program beside it:
import taji
p = taji.plugin()
ROWS = [{"ts_utc": 1704153600, "price": "20.25", "size": 100.0}]
@p.read("toyfeed.levels")
def read(ask):
if ask["asked"] != "$TOY":
raise taji.Refused(404, "not_listed", f"no {ask['asked']}")
lo, hi = ask["from"], ask["to"]
rows = [r for r in ROWS if (lo is None or r["ts_utc"] >= lo) and (hi is None or r["ts_utc"] < hi)]
return rows[: ask["limit"]] if ask["limit"] is not None else rows
p.run()
p = taji.plugin()readstaji-plugin.tomlbeside the script.@p.read("toyfeed.levels")registers the handler for each read of the product.askis aReadAsk:askedis the item's canonical key ($TOY, forindex:TOY),fromandtoare UTC seconds,[from, to), andlimitis the most rows asked; each isnullwhen the reader leaves it open (the protocol reference). The rows it returns are the answer.raise taji.Refused(404, "not_listed", …)refuses an item the source does not carry. An unpinned read then falls past this source to the next one serving the product.p.run()says hello to the kernel and serves calls until the kernel closes stdin. It refuses to start when a product of[[sources]]has no@p.read.
For a live read, add @p.stream: async def stream(sub) runs once per sub, the SDK cancels it when the sub leaves the set, and one that raises ends only its own sub. For a source that signs in, add @p.check. Both are in plugins/pyfeed/pyfeed.py and the SDK's docstring.
3. Load it
Put toyfeed/ in a directory of plugins and, at the checkout's root, boot a headless kernel on new state with TAJI_PLUGINS naming that directory. A debug kernel runs Python plugins on the checkout's .python; TAJI_PYTHON names another.
mkdir -p my-plugins && cp -R toyfeed my-plugins/
export TAJI_STATE_DIR=$(mktemp -d) TAJI_STORE_DIR=$(mktemp -d) TAJI_HOME=$(mktemp -d) TAJI_WIRE=0
TAJI_PLUGINS=$PWD/my-plugins TAJI_HEADLESS=1 target/debug/taji &
The kernel writes its port to $TAJI_STATE_DIR/wire-port and its token to $TAJI_STATE_DIR/wire-token (the wire reference). To publish the plugin instead, pack it into a signed registry.
4. Read it
Ask the wire for toyfeed.levels like any product. The answer is Arrow IPC, so decode it with pyarrow:
PORT=$(cat $TAJI_STATE_DIR/wire-port) TOKEN=$(cat $TAJI_STATE_DIR/wire-token)
curl -sf -H "x-taji-token: $TOKEN" "localhost:$PORT/get/toyfeed.levels?symbols=index:TOY&from=2024-01-01&to=2024-02-01" \
| .python/python -c "import sys, pyarrow as pa; t = pa.ipc.open_stream(sys.stdin.buffer).read_all(); print(t.schema.metadata, t.to_pylist())"
target/debug/taji quit
The rows, with the schema's metadata beside them:
{
"metadata": {
"computed_by": "{\"plugin\":\"toyfeed\",\"version\":\"0.1.0\"}",
"provider": "{\"index:$TOY\":\"toyfeed\"}",
"source": "{\"index:$TOY\":\"vendor\"}"
},
"rows": [
{
"ts_utc": 1704153600,
"price": 20.25,
"size": 100.0,
"knowable_utc": 1796329342,
"recorded": false,
"version": "0.1.0"
}
]
}
The row is the plugin's, its price a decimal on the wire (Decimal128(38, 10)). The kernel adds three columns to every row of a plugin's product: knowable_utc, the second the row became known (here the moment of the read, since the plugin read no input), recorded, false for a row the source answered rather than Taji's store, and version, the plugin's. In the metadata, provider maps each item to the source that answered it and computed_by names the plugin. Any symbol but index:TOY answers 404 not_listed.
Captured 2026-12-03 on a keyless headless kernel with toyfeed in its TAJI_PLUGINS.
If it fails
- The plugin exits at once, and its log,
$TAJI_STATE_DIR/plugins/toyfeed/log, saystaji-plugin: its taji-plugin.toml needs a handler it does not register: a product of[[sources]]has no@p.read. Register one handler per declared product beforep.run(). GET /read/pluginsshows the pluginenabled: falsewith areasonstartingno sandbox:: the OS sandbox is not available here, and the reason names what it needs. On a debug kernel,TAJI_UNSANDBOXED=1runs plugins unconfined; a release kernel ignores it.
Next
- Your CSV as a data source: the same shape, reading a file of your own.
- The process protocol: every call and row shape a source answers.
- Pack and install from a signed registry.
- A provider: a compiled-in source or brokerage.