Every operation is a plain HTTP request. The examples assume a running server on localhost:8080 and the token in $GENESISDB_AUTH_TOKEN. A Postman collection with the same requests is available as well.
Commit 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",
"type": "io.genesisdb.app.customer-added",
"data": { "firstName": "Bruce", "lastName": "Wayne", "emailAddress": "bruce.wayne@enterprise.wayne" }
},
{
"source": "io.genesisdb.store",
"subject": "/article",
"type": "io.genesisdb.store.article-added",
"data": { "name": "Tumbler", "color": "black", "price": 2990000.00 }
}
]
}'Commit with a precondition
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/42", "type": "io.genesisdb.app.customer-added", "data": { "name": "Bruce" } }
],
"preconditions": [
{ "type": "isSubjectNew", "payload": { "subject": "/customer/42" } }
]
}'Commit erasable personal data
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/42",
"type": "io.genesisdb.app.customer-added",
"data": { "name": "Bruce Wayne", "email": "bruce@wayne.enterprises" },
"options": { "storeDataAsReference": true }
}
]
}'Fetch
curl localhost:8080/api/v2/fetch \
-H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" \
-d '{ "subject": "/customer" }'
curl localhost:8080/api/v2/fetch \
-H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" \
-d '{ "subject": "/customer", "options": { "lowerBound": "<event id>", "includeLowerBoundEvent": false } }'
curl localhost:8080/api/v2/fetch \
-H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" \
-d '{ "subject": "/customer/42", "options": { "latestByEventType": "io.genesisdb.app.customer-added" } }'Subscribe
curl -N localhost:8080/api/v2/subscribe \
-H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" \
-d '{ "subject": "/customer", "interval": 1 }'-N disables buffering, so new events appear as soon as they are committed.
Query
curl localhost:8080/api/v2/query \
-H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" \
-d "{ \"query\": \"STREAM e FROM events WHERE e.subject UNDER '/customer' ORDER BY e.time DESC MAP { id: e.id, firstName: e.data.firstName }\" }"Subjects and types
curl localhost:8080/api/v2/subjects -H "Authorization: Bearer $GENESISDB_AUTH_TOKEN"
curl localhost:8080/api/v2/types -H "Authorization: Bearer $GENESISDB_AUTH_TOKEN"Schemas
curl localhost:8080/api/v2/schemas \
-H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "io.genesisdb.app.customer-added",
"schema": {
"type": "object",
"properties": { "firstName": { "type": "string" }, "lastName": { "type": "string" } },
"required": ["firstName"],
"additionalProperties": true
}
}'
curl localhost:8080/api/v2/schemas -H "Authorization: Bearer $GENESISDB_AUTH_TOKEN"Erase
curl localhost:8080/api/v2/admin/erase \
-H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "subject": "/customer/42" }'Status, audit and ping
curl localhost:8080/ping
curl localhost:8080/api/v2/status -H "Authorization: Bearer $GENESISDB_AUTH_TOKEN"
curl localhost:8080/api/v2/admin/audit -H "Authorization: Bearer $GENESISDB_AUTH_TOKEN"Backup and restore
curl localhost:8080/api/v2/admin/backup -H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" -o backup.json
curl localhost:8080/api/v2/admin/restore \
-H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" \
-H "Content-Type: application/json" \
--data-binary @backup.jsonRebuild indexes
curl -X POST localhost:8080/api/v2/admin/index -H "Authorization: Bearer $GENESISDB_AUTH_TOKEN"