Start GenesisDB
The fastest way is the container image. It is published for linux/amd64 and linux/arm64 on Docker Hub and GitHub Packages.
export GENESISDB_AUTH_TOKEN="$(openssl rand -hex 32)"
docker run --rm --name genesisdb \
-e GENESISDB_AUTH_TOKEN \
-p 127.0.0.1:8080:8080 \
-v genesisdb-data:/app/data \
genesisdb/genesisdb:latestPrefer a native binary? Install it with Go or download it from the releases page:
go install github.com/genesisdb-io/genesisdb/v2/cmd/genesisdb@latest
genesisdbThe token is required and must have at least 32 bytes. The server binds to 127.0.0.1:8080 and stores its data in ./data.
Check that it runs
curl localhost:8080/ping
# PongCommit events
curl localhost:8080/api/v2/commit \
-H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"events": [
{ "source": "io.genesisdb.app", "subject": "/customer/1", "type": "io.genesisdb.app.customer-added", "data": { "name": "Bruce Wayne" } },
{ "source": "io.genesisdb.app", "subject": "/customer/2", "type": "io.genesisdb.app.customer-added", "data": { "name": "Selina Kyle" } }
]
}'The answer contains the stored events with ID, time, hash and predecessor hash, one per line (NDJSON).
Fetch a subject
curl localhost:8080/api/v2/fetch \
-H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" \
-d '{ "subject": "/customer" }'/customer returns the events of /customer and all of its descendants, in commit order.
Query with GDBQL
curl localhost:8080/api/v2/query \
-H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" \
-d "{ \"query\": \"STREAM e FROM events WHERE e.subject UNDER '/customer' MAP { id: e.id, name: e.data.name }\" }"Next steps
- Pick an SDK for your language.
- Learn the query language.
- Read about preconditions and GDPR erasure.
- Configure tokens, TLS and limits in Configuration.