Getting Started

Edit this page on GitHub

Get SirixDB running and query temporal data in minutes. Pick the path that fits your use case:

Path Time Best for
REST API ~5 min Building web/mobile apps, language-agnostic integration
Embedded Java Library ~10 min JVM applications, direct transaction access, full control
CLI Tools ~10 min Ad-hoc queries, scripting, interactive JSONiq

Prerequisites: Docker for the REST API path; for the embedded and CLI paths, see the supported JVM and required launch flags.


REST API

Start a full SirixDB server with Keycloak authentication and interact via curl.

Start the server

git clone https://github.com/sirixdb/sirix.git
cd sirix
docker compose up -d

Wait for Keycloak’s health check to pass, then the SirixDB server starts on http://localhost:9443.

Authenticate

TOKEN=$(curl -sS -X POST "http://localhost:9443/token" \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin"}' \
  | python3 -c "import sys,json; print(json.load(sys.stdin)['access_token'])")

Store a JSON document

curl -sS -X PUT "http://localhost:9443/shop/products?hashType=ROLLING" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '[
    {"name": "Laptop", "price": 999},
    {"name": "Phone",  "price": 699},
    {"name": "Tablet", "price": 449}
  ]'

This creates a JSON database called shop with a resource called products — revision 1.

Read it back

curl -sS "http://localhost:9443/shop/products" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/json"

Update the document (revision 2)

First, get the ETag of the root node:

ETAG=$(curl -sSI "http://localhost:9443/shop/products?nodeId=1" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/json" \
  | grep -i etag | tr -d '\r' | cut -d' ' -f2)

Then insert a new product:

curl -sS -X POST "http://localhost:9443/shop/products?nodeId=1&insert=asFirstChild" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "If-Match: $ETAG" \
  -d '{"name": "Monitor", "price": 349}'

Time travel — read revision 1

curl -sS "http://localhost:9443/shop/products?revision=1" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/json"

Diff two revisions

curl -sS "http://localhost:9443/shop/products/diff?first-revision=1&second-revision=2" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/json"

Temporal JSONiq query

Retrieve all revisions of the entire document:

curl -sS -X POST "http://localhost:9443/" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"query": "jn:all-times(jn:doc(\"shop\",\"products\"))"}'

Tear down

docker compose down -v

For the full endpoint reference, see REST API.


Embedded Java Library

Use SirixDB directly inside your JVM application for direct transaction access and fine-grained control.

Follow the embedded-library setup in the SirixDB README for current Maven and Gradle coordinates and the command to run the example. It distinguishes the published library from source builds.

The standalone embedded example creates an isolated temporary database, commits two revisions, and reads the original value back. Use its source and Maven configuration together.

Key concepts:

For the full cursor API, see Cursor API. For the DOM-alike layer, see DOM-alike API.


CLI Tools

Kotlin CLI

Build and run the Kotlin CLI for basic database operations:

git clone https://github.com/sirixdb/sirix.git
cd sirix
./gradlew :sirix-kotlin-cli:installDist

Usage:

bundles/sirix-kotlin-cli/build/install/sirix-kotlin-cli/bin/sirix-kotlin-cli --help

Interactive JSONiq shell

Launch an interactive shell to run JSONiq queries:

./gradlew :sirix-query:run --args="-iq"

This opens a REPL where you can run temporal queries against local databases. See the JSONiq Tutorial for query examples.


What’s next?