Production URL: wss://api.enclave.market/ws
WebSocket connections go through the following example lifecycle:
wss://api.enclave.market/ws
{"op": "login", "args": {"key": <api_key_id>, "sign": <signature>, "time": <ts>}}
{"op": "ping"}
{"type": "pong"}
{"op": "subscribe", "channel": <channel_name>}
{"type": "subscribed", "channel": <channel_name>}
{"type":"update","channel":"prices","data":{"pair":{"base":"AVAX","quote":"USDC"},"price":"13.879000015258789","time":"2022-11-15T16:18:12.049289984Z"}}
{"op": "unsubscribe", "channel": <channel_name>}
{"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 via API key.
key
- your generated API key IDtime
- String representing Unix epoch in millisecondssign
- hex representation of SHA256 HMAC of the following two strings concatenated together using the API secret: <time>enclave_ws_loginYou can create an API key by following the instructions here.
Example request:
{
"op": "login",
"args": {
"key": "<api_key_id>",
"time": "<timestamp>",
"sign": "<signature>"
}
}
Success response:
{"type":"loggedIn"}
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",
},
}
}
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
}
}