Production URL: wss://api.enclave.market/ws

Connection Lifecycle

WebSocket connections go through the following example lifecycle:

  1. Connect to the API at wss://api.enclave.market/ws
  2. For private channels (orders and fills), authentication is required here. {"op": "login", "args": {"key": <api_key_id>, "sign": <signature>, "time": <ts>}}
  3. Ping at a regular interval (every 15 seconds) with: {"op": "ping"}
  4. Receive a pong response: {"type": "pong"}
  5. Subscribe to a channel with: {"op": "subscribe", "channel": <channel_name>}
  6. Receive subscription response: {"type": "subscribed", "channel": <channel_name>}
  7. Receive an update (public prices channel example): {"type":"update","channel":"prices","data":{"pair":{"base":"AVAX","quote":"USDC"},"price":"13.879000015258789","time":"2022-11-15T16:18:12.049289984Z"}}
  8. (Optional) Unsubscribe from a channel to stop receiving messages: {"op": "unsubscribe", "channel": <channel_name>}
  9. Receive unsubscription response: {"type": "unsubscribed", "channel": <channel_name>}

If there has been no activity on the WebSocket connection for ~3min, it will be disconnected. Activity is either a ping, a successful event update, subscription or unsubscription to a channel. All these events reset the timer.

Authentication

Authentication via API key.

You can create an API key by following the instructions here.

REST API Authentication

Example request:

{
  "op": "login",
  "args": {
    "key": "<api_key_id>",
    "time": "<timestamp>",
    "sign": "<signature>"
  }
}

Success response:

{"type":"loggedIn"}

Deposits

Sends a message whenever a deposit is received on the currently logged in account

// Request
// Subscribe to fills.
{
	"op":"subscribe",
  "channel": "deposits",
   "timeout_seconds": 60
}

// Response
// First will be confirmation about operation success/failure.
{
  "channel": "deposits",
  "type":"subscribed",
  "data": ...
}

{
  "channel": "deposits",
  "type": "subscribed",
  "data": {
		"accountID": "1231234123123",
	  "coin": "AVAX",
	  "amount": "200.500123"
	  "chainID": "43114",
	  "time": "2022-06-16T12:35:11.123456Z"
	  "transfer": {
	    "txn": "0x0cb63d177240402801dcb0388bfc74472b64c2f6f55cc67d10ddfa818a1046c4",
	    "type": "0x2",
	    "nonce": "1234",
	    "contract_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
	    "from": "0x706d602729b932959935c1efd350cea74527d3d0",
	    "to": "0x85033fba5d2a988c4134344967d1a57ea392f059",
	    "amount": "1000000000000000000",
	    "data": "0x0",
	  },
	}
}

Withdrawals

Sends a message when a withdrawal request is received and sends status updates at interval until the withdrawal is complete

// Request
{
	"op":"subscribe",
  "channel": "withdrawals",
   "timeout_seconds": 60
}

// Response
// First will be confirmation about operation success/failure.
{
  "channel": "withdrawals",
  "type":"subscribed",
  "data": ...
}

{
  "channel": "withdrawals",
  "type":"update",
  "data": {
    "request": {"chain_id": "43114", "withdrawal_id": "12345"},
    "withdrawal_status": enum{"WITHDRAWAL_FAILURE", "WITHDRAWAL_PENDING", "WITHDRAWAL_CANCELLED", "WITHDRAWAL_UNKNOWN", "WITHDRAWAL_SUCCESS"},
    "transaction_id": "0x0cb63d177240402801dcb0388bfc74472b64c2f6f55cc67d10ddfa818a1046c4",
    "confirmations": 8
  } 
}

Message Ordering

Within a particular channel the messages are always guaranteed to be ordered by the time of creation. But there is no particular order guarantee on the delivery of these events between different channels. This means you could in theory receive fill message first and then top of book update message, or vice versa.

Errors