SealQuery

Developer docs

Integrate a private-data answer.

One REST call or MCP tool for the full loop: quote, pay, execute, verify, and settle. The response is an aggregate plus a proof — never raw rows.

Quickstart

Start the API and the Next.js app, then run the first query. The browser console and the REST API hit the same real testnet flow.

# terminal 1: FastAPI export CONTRACT_ACCOUNT='<v2 contract>' export AGENT_ACCOUNT='<agent account>' export SEALQUERY_API_KEY='<local-demo-key>' ./scripts/run_backend.sh # terminal 2: Next.js app cd frontend pnpm install API_URL=http://127.0.0.1:8000 pnpm dev

The FastAPI service is served at :8000; the Next.js app is served at :3000 and proxies /api to it.

REST API

The browser route is same-origin and key-free. Machine clients use /api/v1/query with an API key and idempotency key.

Run a query

curl -s http://127.0.0.1:8000/api/query \
  -H 'Content-Type: application/json' \
  -d '{"dataset_id":"retail_v1","computation_id":"spend_growth_v1"}' | jq

Machine query

curl -s http://127.0.0.1:8000/api/v1/query \
  -H "X-API-Key: $SEALQUERY_API_KEY" \
  -H 'Idempotency-Key: demo-1' \
  -H 'Content-Type: application/json' \
  -d '{"dataset_id":"retail_v1"}' | jq
EndpointPurpose
GET /api/statedatasets, budgets, recent queries
GET /api/metricsalerts, balances, query status
GET /api/queriesagent query history
GET /api/queries/:idone query record
POST /api/queryenqueue browser query; 202 + job_id
GET /api/jobs/:job_idpoll browser job
GET /api/owner/summaryindexed owner earnings
POST /api/v1/queryenqueue machine query; X-API-Key
GET /api/v1/jobs/:job_idpoll machine job
GET /api/attestation/:txstructured TDX report
GET /api/attestation/:tx/bundledownload proof bundle

MCP

Expose SealQuery as tools to Claude, Cursor, or any MCP client. run_query performs a real paid testnet query and returns the aggregate plus proof metadata.

Client configuration

{
  "mcpServers": {
    "sealquery": {
      "command": "python3",
      "args": ["mcp/server.py"],
      "env": {
        "SEALQUERY_API_URL": "http://127.0.0.1:8000",
        "SEALQUERY_API_KEY": "<your key>"
      }
    }
  }
}
list_datasetsquoterun_queryget_queryverify_query

Contract

NEAR testnet · escrow, dataset registry, privacy budget, query history, acceptance, refunds.

Proof verification

Do not trust the UI badge. Verify the transaction or the downloaded bundle independently.

Verify

outlayer-verify tx <request-tx-hash> \
  --network testnet \
  --api https://testnet-api.outlayer.ai \
  --json

outlayer-verify bundle proof.json --offline --short

A valid result must pass authenticity, identity, binding, input, and output; TCB should be UpToDate.

Limitations

  • • Testnet only; NEAR testnet payments and OutLayer testnet compute.
  • • Public dataset used as a private-data stand-in.
  • • No differential privacy; budget + cohort + rounding are the current controls.
  • • OutLayer governance is centralized; the TEE proves what ran, not correctness.
  • • No token, no mainnet deployment, no human wallet flow yet.

Self-host

The canonical deployment is a Docker Compose stack: Next.js web, FastAPI API, indexer, Postgres, Redis, and Caddy. The hosted mirror uses Render + Neon. Docker builds near-cli-rs and outlayer-verify from source for the backend image.

cp .env.example .env # fill CONTRACT_ACCOUNT, AGENT_ACCOUNT, SEALQUERY_API_KEY, # NEAR_ACCESS_KEY_FILE docker compose up --build

Open http://127.0.0.1:8080. Caddy routes /api to FastAPI and the rest to Next.js.