WebSockets

Streams & Commands

wss://api.bondis.xyz/v1/stream (testnet analogous)

Bondis WS supports command parity with REST (orders, transfers, PBV, bridge report), plus market/account streams.

Auth (first frame)

Embed signature in authz. h is keccak of the JCS-canonical frame without authz.

{
  "v": 1,
  "op": "auth",
  "seq": 1,
  "timestamp": 1736371200123,
  "authz": { "alg": "secp256k1-keccak-eip712", "h": "0x...", "sig": "0x..." }
}

Send commands (signed)

Single command (place order):

{
  "v": "1c",
  "op": "n",
  "m": "USD/BRL",
  "s": "b",
  "r": "maker",
  "t": "limit",
  "p": "5.1234",
  "q": "10000",
  "cid": "abc-123",
  "seq": 2,
  "timestamp": 1736371201200,
  "authz": { "alg": "secp256k1-keccak-eip712", "h": "0x...", "sig": "0x..." }
}

Batch:

{
  "v": "1c",
  "op": "batch",
  "ops": [
    { "id": "a1", "op": "c", "oid": "ord_..." },
    { "id": "a2", "op": "n", "m": "USD/BRL", "s": "s", "r": "taker", "t": "market", "q": "5000" }
  ],
  "seq": 3,
  "timestamp": 1736371202200,
  "authz": { "alg": "secp256k1-keccak-eip712", "h": "0x...", "sig": "0x..." }
}

Ack frame (server → client):

{ "op": "ack", "corr": "a2?", "status": "accepted|rejected", "reason": "REJECT_MARGIN", "block_id": "b_104952" }

Subscriptions

Subscribe to book, trades, orders, oracle, pbv.

{
  "v": 1,
  "op": "subscribe",
  "channels": [
    { "name": "book", "market": "USD/BRL" },
    { "name": "orders", "account": "A123" }
  ],
  "seq": 4,
  "timestamp": 1736371202500,
  "authz": { "alg": "secp256k1-keccak-eip712", "h": "0x...", "sig": "0x..." }
}

Book event example (server → client):

{ "channel": "book", "market": "USD/BRL", "bids": [["5.1232","20000"]], "asks": [["5.1235","15000"]], "block_id": "b_104952" }

Heartbeats, Resume, Backpressure

  • Ping/Pong: server: { "op": "ping", "t": 1736371203000 }; client: { "op": "pong", "t": ... }

  • Resume: { "op": "resume", "last_ack": "b_104950" } to request missed events since a batch id

  • Backpressure: server may send { "op": "backpressure", "max_outstanding": 32 }


Curl Examples

Place a limit buy (REST)

curl -X POST https://api-testnet.bondis.xyz/v1/orders \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bondis alg=secp256k1-keccak-eip712, h=0xabc..., sig=0xdef...' \
  -d '{ "v":"1c","op":"n","m":"USD/BRL","s":"b","r":"maker","t":"limit","p":"5.1234","q":"10000","cid":"abc-123","seq":"42","timestamp":"1736371200123" }'

Response

{ "order_id": "ord_7YQ9", "status": "accepted", "block_id": "b_104952" }

Cancel by market/side (REST)

curl -X POST https://api-testnet.bondis.xyz/v1/orders/cancel \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bondis alg=secp256k1-keccak-eip712, h=0xabc..., sig=0xdef...' \
  -d '{ "v":"1c","op":"c","m":"USD/BRL","s":"both","seq":"43","timestamp":"1736371201123" }'

Response

{ "canceled": 3, "block_id": "b_104952" }

Last updated