HTTP API

Asset Core exposes HTTP APIs through two daemons: the write daemon for commits and the read daemon for queries.

Overview

The API is RESTful with JSON payloads. Both daemons provide health endpoints for monitoring, and responses include freshness metadata where applicable.

The full specification is available in openapi.json in the distribution bundle.

Structure

Write Daemon Endpoints

MethodPathDescription
POST/v1/commitSubmit a transaction
POST/v1/register/classRegister a new asset class
POST/v1/register/class-shapeRegister a shape for a class
GET/v1/healthHealth check with commit log status
GET/v1/metricsPrometheus metrics

Read Daemon Endpoints

MethodPathDescription
GET/v1/read/container/{id}Get container metadata
GET/v1/read/container/{id}/balancesGet container balances
GET/v1/read/container/{id}/slotsGet container slots
GET/v1/read/container/{id}/gridGet container grid
GET/v1/read/class/{id}Get class details
GET/v1/read/classesList registered classes
GET/v1/read/class/{id}/shapesGet class shapes
GET/v1/read/class/{id}/statsGet class statistics
GET/v1/read/freshnessGet freshness metadata
GET/v1/healthHealth check

Fields

Request Headers

HeaderRequiredDescription
Content-TypeYesMust be application/json for POST requests
X-Idempotency-KeyNoAlternative to request body field

Response Headers

HeaderDescription
X-Asset-Idempotencyhit if response was cached
Content-TypeAlways application/json

Common Response Fields

Success responses include:

{
  "global_seq": 42,
  "batch_seq": 1,
  "minted_instances": [9001, 9002],
  "metadata": { ... }
}

Query responses include freshness:

{
  "data": { ... },
  "freshness": {
    "checkpoint_seq": 42,
    "commit_log_seq": 45
  }
}

Examples

Submit a Transaction

curl -X POST http://localhost:8080/v1/commit \
  -H "Content-Type: application/json" \
  -d '{
    "operations": [
      {
        "op": "CreateContainer",
        "args": {
          "container_id": 1001,
          "kind": "Standard",
          "owner": null
        }
      }
    ],
    "idempotency_key": "create-container-1001"
  }'

Response:

{
  "global_seq": 1,
  "batch_seq": 1,
  "minted_instances": [],
  "metadata": {
    "idempotency_key": "create-container-1001"
  }
}

Query Container Balances

curl http://localhost:8081/v1/read/container/1001/balances

Response:

{
  "container_id": 1001,
  "balances": [
    {
      "class_id": 100,
      "key": 1,
      "quantity": 500
    }
  ],
  "freshness": {
    "checkpoint_seq": 1,
    "commit_log_seq": 1
  }
}

Check Health

curl http://localhost:8080/v1/health

Response:

{
  "status": "healthy",
  "commit_log": {
    "end_seq": 100,
    "checkpoint_seq": 100,
    "lag": 0,
    "driver": {
      "name": "file",
      "path": "/var/lib/assetcore/commit_log.log"
    }
  }
}