_Docs/
Get StartedModulesPlatformDeployCookbookChangelogReference
_Stack
_Modules
  • Ledger
    • Quick Start
    • Core Concepts
      • Accounts
      • Transactions
      • Constraints
      • Source/destination
      • Designing a Chart of Accounts
    • Working with the Ledger
      • Assets & Currency conversion
      • Bi-temporality
      • Bulk processing
      • Filtering queries
      • Idempotency
      • Data isolation with buckets
      • From credit/debit to source/destination
      • Streaming to analytics systems
      • Ledger Schema
    • Advanced Topics
      • Architecting for scale
      • Events Publishers
      • Performance model
  • Numscript
  • Connectivity
  • WalletsEE
  • FlowsEE
  • ReconciliationEE
  1. Modules
  2. Ledger
  3. Working with the Ledger
  4. Streaming to analytics systems
Ledger

Streaming to analytics systems

Stream your ledger data in real-time to analytics systems like ClickHouse, Elasticsearch, or custom HTTP endpoints. This lets you build dashboards, enable full-text search, or trigger external workflows—without polling the API.

Architecture#

The export system has two components: exporters define where data goes (driver + connection config), and pipelines connect a ledger to an exporter. Multiple ledgers can share the same exporter.

What gets streamed#

Every change to your ledger is recorded as a log entry. Pipelines stream these logs to your chosen destination:

EventDescription
SET_METADATALog entry for setting metadata on an account or transaction
NEW_TRANSACTIONLog entry for creating a new transaction with associated account metadata
REVERTED_TRANSACTIONLog entry for reverting an existing transaction
DELETE_METADATALog entry for deleting metadata from an account or transaction
INSERTED_SCHEMALog entry for inserting a new ledger schema
COMMITTED_TRANSACTIONSExternal event published when transactions are committed to the ledger
SAVED_METADATAExternal event published when metadata is saved on an entity
DELETED_METADATAExternal event published when metadata is deleted from an entity

Quick start#

Here's the complete flow to start streaming data:

1. Create an exporter (defines where data goes)

curl -X POST $FORMANCE_API_URL/api/ledger/v2/_/exporters \
  -H "Content-Type: application/json" \
  -d '{
    "driver": "clickhouse",
    "config": {
      "dsn": "clickhouse://localhost:9000"
    }
  }'
POST/api/ledger/v2/_/exporters

Response:

JSON
{
  "data": {
    "id": "exp-abc123",
    "driver": "clickhouse",
    "config": { "dsn": "clickhouse://localhost:9000" },
    "createdAt": "2025-01-15T10:00:00Z"
  }
}

2. Create a pipeline (connects a ledger to the exporter)

curl -X POST $FORMANCE_API_URL/api/ledger/v2/my-ledger/pipelines \
  -H "Content-Type: application/json" \
  -d '{
    "exporterID": "exp-abc123"
  }'
POST/api/ledger/v2/my-ledger/pipelines

Pipelines start automatically. Logs begin streaming immediately.

Exporter drivers#

Your endpoint receives a JSON array of log entries:

JSON
[
  {
    "ledger": "my-ledger",
    "id": 42,
    "type": "NEW_TRANSACTION",
    "date": "2025-01-15T10:30:00Z",
    "data": {
      "transaction": {
        "id": 1,
        "postings": [...],
        "metadata": {}
      }
    }
  }
]

Return a 2xx status code to acknowledge receipt.

Managing exporters#

List all exporters:

curl -X GET $FORMANCE_API_URL/api/ledger/v2/_/exporters
GET/api/ledger/v2/_/exporters

Get a specific exporter:

curl -X GET $FORMANCE_API_URL/api/ledger/v2/_/exporters/<EXPORTER_ID>
GET/api/ledger/v2/_/exporters/<EXPORTER_ID>

Delete an exporter:

curl -X DELETE $FORMANCE_API_URL/api/ledger/v2/_/exporters/<EXPORTER_ID>
DELETE/api/ledger/v2/_/exporters/<EXPORTER_ID>

Managing pipelines#

Check pipeline status#

curl -X GET $FORMANCE_API_URL/api/ledger/v2/my-ledger/pipelines/<PIPELINE_ID>
GET/api/ledger/v2/my-ledger/pipelines/<PIPELINE_ID>

The lastLogID shows how far the pipeline has progressed:

JSON
{
  "data": {
    "id": "pipe-xyz789",
    "ledger": "my-ledger",
    "exporterID": "exp-abc123",
    "lastLogID": 1042,
    "enabled": true,
    "createdAt": "2025-01-15T10:00:00Z"
  }
}

Stop and restart#

Pipelines remember their position. Stop and start without losing progress:

Stop streaming:

curl -X POST $FORMANCE_API_URL/api/ledger/v2/my-ledger/pipelines/<PIPELINE_ID>/stop
POST/api/ledger/v2/my-ledger/pipelines/<PIPELINE_ID>/stop

Resume streaming:

curl -X POST $FORMANCE_API_URL/api/ledger/v2/my-ledger/pipelines/<PIPELINE_ID>/start
POST/api/ledger/v2/my-ledger/pipelines/<PIPELINE_ID>/start

Replay from the beginning#

Reset the pipeline to re-stream all logs:

curl -X POST $FORMANCE_API_URL/api/ledger/v2/my-ledger/pipelines/<PIPELINE_ID>/reset
POST/api/ledger/v2/my-ledger/pipelines/<PIPELINE_ID>/reset

This replays all historical logs. Make sure your destination can handle duplicates or clear it first.

Delete a pipeline#

curl -X DELETE $FORMANCE_API_URL/api/ledger/v2/my-ledger/pipelines/<PIPELINE_ID>
DELETE/api/ledger/v2/my-ledger/pipelines/<PIPELINE_ID>

You cannot delete an exporter that has active pipelines connected to it. Delete or reassign the pipelines first.

Scaling with multiple pipelines#

You can attach multiple ledgers to the same exporter. This helps avoid rate limits on external systems, spread load, and maintain independent data flows per ledger.

curl -X POST $FORMANCE_API_URL/api/ledger/v2/ledger-001/pipelines \
  -H "Content-Type: application/json" \
  -d '{
    "exporterID": "<EXPORTER_ID>"
  }'
POST/api/ledger/v2/ledger-001/pipelines

Repeat for each ledger — all pipelines share the same exporter.

From credit/debit to source/destinationLedger Schema
On This Page
  • Architecture
  • What gets streamed
  • Quick start
  • Exporter drivers
  • Managing exporters
  • Managing pipelines
  • Check pipeline status
  • Stop and restart
  • Replay from the beginning
  • Delete a pipeline
  • Scaling with multiple pipelines