Websocket API

After establishing an authenticated Websocket connection, issue one or more Subscribe messages to subscribe to topics of interest. funkybit will then publish Publish messages as there is updated information. When no longer interested in a topic, issue an Unsubscribe message.

Subscriptions are formatted like this for market-specific topics:

{"type": "Subscribe", "topic": {"type": TOPIC, "marketId": "AAA/BBB"}}

Or like this for topics across markets:

{"type": "Subscribe", "topic": {"type": TOPIC}}

Publishes are formatted like this:

{"type": "Publish", "topic": {"type": TOPIC, ...}, "data": {...}}

Available Topics

IncrementalOrderBook - Market specific

Sample published data:

{
  "type": "IncrementalOrderBook",
  "marketId": "AAA/BBB",
  "buy": [
    {"price": "17.50", "size": "123456789"},
  ],
  "sell": [
    {"price": "18.00", "size": "234567890"},
  ],
  "last": {"price": "17.75", "direction": "Up"}
}

When first subscribing to IncrementalOrderBook a complete order book snapshot is returned. Subsequently, when the order book changes, only the changed levels will be reported.

Prices - Market specific

Immediately after subscribing, the last week of prices at 5 minute intervals will be published. The full field will be set to true in this case. Subsequently, new price data will be published as it occurs. Sample published data:

{
  "type": "Prices",
  "market": "AAA/BBB",
  "duration": "P5M", 
  "ohlc": [{
    "start": "2024-04-08T19:41:15.636416758Z",
    "open": "18.02",
    "high": "18.05",
    "low": "18.01",
    "close": "18.03",
    "duration": "300000"
  }],
  "full": false,
  "dailyChange": -1.2
} 

Possible duration values are "P1M", "P5M", "P15M" "P1H", "P4H", "P1D".

MarketTrades - Market specific

Sample published data:

{
  "type": "MarketTradesCreated",
  "sequenceNumber": 123,
  "marketId": "AAA/BBB",
  "trades": [
    ["trade_01hv79t3rrf9kt7t7pys01gjcn", "Buy", "123456789", "18.03", 1722001494355],
  }]
}

When first subscribing, no initial message is sent, but as trades occur in that market, a message will be published. Each element in the trades array contains an arry with 5 items. The first is the trade id, the second is the trade side, the third is the amount, the fourth is the price, and the fifth is the timestamp (in epoch milliseconds).

MyTrades

Sample published data:

{
  "type": "MyTrades",
  "trades": [{
    "id": "trade_01hv79t3rrf9kt7t7pys01gjcn",
    "timestamp": "2024-04-08T19:41:15.636416758Z",
    "orderId": "order_01hv79t3rbfgcr4dg41qxp7k62",
    "marketId": "AAA/BBB",
    "executionRole": "Taker",
    "counterOrderId": "order_01hv79t3rbfgcr4dg41qxp7k63"
    "side": "Buy",
    "amount": "1234567689",
    "price": "18.03",
    "feeAmount": "5000",
    "feeSymbol": "BBB",
    "settlementStatus": "Pending",
    "error": null
  }]
}

If populated, error will be a string

Possible execution roles are "Taker", "Maker".

Possible settlement statuses are "Pending", "Settling", "PendingRollback", "FailedSettling", "Completed", "Failed".

When first subscribing, all current trades will be returned. Subsequently, when trades are created or have settlement status changes, an appropriate message will be published:

{
  "type": "MyTradesCreated",
  "trades": [{
    ...
  }]
}
{
  "type": "MyTradesUpdated",
  "order": {
    ...
  }
}

MyOrders

Sample published data:

{
  "type": "MyOrders",
  "orders": [{
    "type": "market",
    "id": "order_01hv79t3rbfgcr4dg41qxp7k62",
    "status": "Filled",
    "marketId": "AAA/BBB",
    "side": "Buy",
    "amount": "123456789",
    "originalAmount": "123456789",
    "executions": [{
      "tradeId": "trade_01hv79t3rrf9kt7t7pys01gjcn",
      "timestamp": "2024-04-08T19:41:15.636416758Z",
      "amount": "123456789",
      "price": "18.03",
      "role": "Taker",
      "feeAmount": "500",
      "feeSymbol": "BBB",
      "marketId": "AAA/BBB",
    }],
    "timing": {
      "createdAt": "2024-04-08T19:41:15.636416758Z",
      "updatedAt": null,
      "closedAt": "2024-04-08T19:41:15.636416758Z",
      "sequencerTimeNs": "211431"
    },
  }]
}

Possible order types are: "market", "limit", "backToBackMarket"

Orders with type "limit" will also have a "price" field.

Orders with type "backToBackMarketId" will also have a "secondMarketId" field.

Possible order statuses are: "Open", "Partial", "Filled", "Cancelled", "Expired", "Rejected", "Failed", "AutoReduced"

Possible execution roles are: "Maker", "Taker"

When first subscribing, all current orders will be returned. Subsequently, when an order is added or cancelled, an appropriate message will be published:

{
  "type": "MyOrderCreated",
  "order": {
    ...
  }
}
{
  "type": "MyOrderUpdated",
  "order": {
    ...
  }
}

Balances

Sample published data:

{
  "type": "Balances",
  "balances": [
    {
      "symbol": "AAA",
      "total": "123456789",
      "available": "12345678",
      "lastUpdated": "2024-04-08T19:41:15.636416758Z"
    },
  ]
}

Limits

Sample published data:

{
  "type": "Limits",
  "limits": [
    ["AAA/BBB", "123456789", "987654321"],
  ]
}

This reports the remaining trading limits on a per-market basis. Each element in the limits array contains an array with 3 items. The first is the market id, the second is the limit for the base asset, and the third is the limit for the quote asset.

Last updated