You will need to create an API key on the platform before you can use authenticated APIs. To create API keys, you can follow the steps below:
Account
on the top right hand cornerNew API
button to create an API key and passphrase. (Note: the passphrase will only appear once)The WS Auth requires to send a payload with the Auth data in the Args key after doing the connection and before sending any other data. see Spot Authentication and Futures Authentication for details.
You might get 400
status code due to abnormal usage and we will block you for 10 minutes.
For connectivity checking, we will send a ping frame message every 3 minutes
and you will need to respond pong frame message to us for checking, if the pong frame message doesn't correctly respond to us in 10 minutes
, we will force to disconnect the connection.
Endpoint: /ws/spot
Subscribe to a topic
Accepts the following message:
To subscribe to a websocket feed
Request Contents
{
"op": "subscribe",
"args": [
"topic-name"
]
}
Response Contents
{
"event": "subscribe",
"channel": [
"topic-name"
]
}
Response Contents
{
"event": "subscribe",
"channel": []
}
Public Trade Fills
Endpoint: /ws/spot
Accepts the following message:
Subscribe to recent trade feed for a market. The topic will be tradeHistoryApi:<market>
where <market>
is the market symbol.
*** response content ***
Request Contents
{
"op": "subscribe",
"args": [
"tradeHistoryApi:BTC-USD"
]
}
Response Contents
{
"topic": "tradeHistoryApi:BTC-USD",
"data": [
{
"symbol": "BTC-USD",
"side": "SELL",
"size": 0.007,
"price": 5302.8,
"tradeId": "<Trade Sequence ID>",
"timestamp": 1584446020295
}
]
}
Spot Authentication
Endpoint: /ws/spot
Accepts the following message:
Authenticate the websocket session to subscribe to authenticated websocket topics. Assume we have values as follows:
- request-nonce
: 1624985375123
- request-api
:4e9536c79f0fdd72bf04f2430982d3f61d9d76c996f0175bbba470d69d59816x
- secret
:848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx
Our subscription request will be:
Request Parameters
Below details the arguments needed to be sent in.
Generating a signature
echo -n "/ws/spot1624985375123" | openssl dgst -sha384 -hmac "848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx"
(stdin)=c410d38c681579adb335885800cff24c66171b7cc8376cfe43da1408c581748156b89bcc5a115bb496413bda481139fb
Request Contents
{
"op": "login",
"args": [
"4e9536c79f0fdd72bf04f2430982d3f61d9d76c996f0175bbba470d69d59816x",
"1624985375123",
"c410d38c681579adb335885800cff24c66171b7cc8376cfe43da1408c581748156b89bcc5a115bb496413bda481139fb"
]
}
Response Contents
{
"event": "login",
"success": true
}
Spot Notifications
Endpoint: /ws/spot
Accepts the following message:
Receive trade notifications by subscribing to the topic notificationApiV3
. The websocket feed will push trade level notifications to the subscriber. If topic is subscribed without being authenticated, no messages will be sent.
*** response content ***
Request Contents
{
"op": "subscribe",
"args": [
"notificationApiV3"
]
}
Response Contents
{
"topic": "notificationApiV3",
"data": [
{
"symbol": "Market Symbol (eg. BTC-USD)",
"orderID": "internal order ID",
"side": "BUY",
"orderType": null,
"price": "Order price or transacted price",
"originalOrderBaseSize": 1,
"originalOrderQuoteSize": 1,
"currentOrderBaseSize": 1,
"currentOrderQuoteSize": 1,
"filledBaseSize": 1,
"totalFilledBaseSize": 1,
"remainingBaseSize": 1,
"remainingQuoteSize": 1,
"orderCurrency": "base",
"avgFilledPrice": 35000,
"status": "<Refer to Status description on the left>",
"clOrderID": "<Client order ID>",
"maker": "<Maker flag, if true indicates that trade is a maker trade>",
"stealth": 1,
"timestamp": 1624985375123,
"pegPriceDeviation": "Indicate the deviation percentage. Valid for only algo orders.",
"remainingSize": "<Remaining size on the order>",
"time_in_force": "<Time where this order is valid>",
"txType": 0,
"triggerPrice": "Trade Trigger Price"
}
]
}
Spot User Trade Fills
Endpoint: /ws/spot
Accepts the following message:
When a trade has been transacted, this topic will send the trade information back to the subscriber.
Request Contents
{
"op": "subscribe",
"args": [
"fills"
]
}
Response Contents
{
"topic": "fills",
"data": [
{
"orderId": "<Order Id>",
"serialId": "<Serial ID After Insertion into DB>",
"clOrderId": "<Client order ID>",
"type": "order type",
"symbol": "ex: BTC-USD",
"side": "BUY|SELL",
"price": "filled price",
"size": "filled size",
"feeAmount": "Fees charged to user, value to be String on API",
"feeCurrency": "Fee currency, eg. Buy would be BTC, Sell would be USD",
"base": "Base currency, eg. BTC",
"quote": "Quote currency eg. USD",
"maker": "maker or taker",
"timestamp": "Time trade was matched in the engine",
"tradeId": "<Trade Unique ID>"
}
]
}
OSS Level 1 Orderbook Snapshot
Endpoint: /ws/oss/spot
The format to subscribe to will be symbol
.
The L1 orderbook will be pushed immediately when orderbook changes.
Accepts the following message:
*** response content ***
Request Contents
{
"op": "subscribe",
"args": [
"snapshotL1:BTC-USD"
]
}
Request Contents
{
"op": "unsubscribe",
"args": [
"snapshotL1:BTC-USD"
]
}
Response-Subscribe Contents
{
"topic": "snapshotL1:BTC-USD",
"data": {
"bids": [
[
"28016.7",
"1.48063"
]
],
"asks": [
[
"28033.6",
"1.34133"
]
],
"type": "snapshotL1",
"symbol": "BTC-USD",
"timestamp": 1680750154232
}
}
Orderbook Incremental Updates
Endpoint: /ws/oss/spot
Subscribe to Orderbook incremental updates through the endpoint /ws/oss/spot. The topic to subscribe to will be update
specifying the symbol (eg. update:BTC-USD
). The first response received will be a snapshot of the current orderbook (this is indicated in the type
field) and 50 levels will be returned. Incremental updates will be sent in subsequent packets with type delta
.
Bids and asks will be sent in price
and size
tuples. The size sent will be the new updated size for the price. If a value of 0 is sent, the price should be removed from the local copy of the orderbook.
To ensure that the updates are received in sequence, seqNum
indicates the current sequence and prevSeqNum
refers to the packet before. seqNum will always be one after the prevSeqNum. If the sequence is out of order, you will need to unsubscribe and re-subscribe to the topic again.
Also if crossed orderbook
ever occurs when the best bid higher or equal to the best ask, please unsubscribe and re-subscribe to the topic again.
*** response content ***
Accepts the following message:
*** response content ***
Request Contents
{
"op": "subscribe",
"args": [
"update:BTC-USD"
]
}
Request Contents
{
"op": "unsubscribe",
"args": [
"update:BTC-USD"
]
}
Response-Subscribe Contents
{
"topic": "update:BTC-USD",
"data": {
"bids": [
[
"59252.5",
"0.06865"
],
[
"59249.0",
"0.24000"
],
[
"59235.5",
"0.16073"
],
[
"59235.0",
"0.26626"
],
[
"59233.0",
"0.50000"
]
],
"asks": [
[
"59292.0",
"0.50000"
],
[
"59285.5",
"0.24000"
],
[
"59285.0",
"0.15598"
],
[
"59282.5",
"0.06829"
],
[
"59278.5",
"0.01472"
]
],
"seqNum": 628282,
"prevSeqNum": 628281,
"type": "snapshot",
"timestamp": 1565135165600,
"symbol": "BTC-USD"
}
}
Response-Unsubscribe Contents
{
"topic": "update:BTC-USD",
"data": {
"bids": [],
"asks": [
[
"59367.5",
"2.15622"
],
[
"59325.5",
"0"
]
],
"seqNum": 628283,
"prevSeqNum": 628282,
"type": "delta",
"timestamp": 1565135165600,
"symbol": "BTC-USD"
}
}
Futures Subscription
Endpoint: /ws/futures
Accepts the following message:
To subscribe to a websocket feed
Request Contents
{
"op": "subscribe",
"args": [
"topic-name"
]
}
Response Contents
{
"event": "subscribe",
"channel": [
"topic-name"
]
}
Response Contents
{
"event": "subscribe",
"channel": []
}
Futures Public Trade Fills
Endpoint: /ws/futures
Accepts the following message:
Subscribe to recent trade feed for a market. The topic will be tradeHistoryApiV2:<market>
where <market>
is the market symbol.
*** response content ***
Request Contents
{
"op": "subscribe",
"args": [
"tradeHistoryApiV2:BTC-PERP"
]
}
Response Contents
{
"topic": "tradeHistoryApiV2:BTC-PERP",
"data": [
{
"symbol": "BTC-PERP",
"side": "SELL",
"size": 0.007,
"price": 5302.8,
"tradeId": "<Trade Sequence ID>",
"timestamp": 1584446020295
}
]
}
Futures Authentication
Endpoint: /ws/futures
Accepts the following message:
Authenticate the websocket session to subscribe to authenticated websocket topics. Assume we have values as follows:
- request-nonce
: 1624985375123
- request-api
:4e9536c79f0fdd72bf04f2430982d3f61d9d76c996f0175bbba470d69d59816x
- secret
:848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx
Our subscription request will be:
Request Parameters
Below details the arguments needed to be sent in.
Generating a signature
echo -n "/ws/futures1624985375123" | openssl dgst -sha384 -hmac "848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx"
(stdin)=bd8afb8bee58ba0a2c67f84dcfe6e64d0274f55d064bb26ea84a0fe6dd8c621b541b511982fb0c0b8c244e9521a80ea1
Request Contents
{
"op": "login",
"args": [
"4e9536c79f0fdd72bf04f2430982d3f61d9d76c996f0175bbba470d69d59816x",
"1624985375123",
"bd8afb8bee58ba0a2c67f84dcfe6e64d0274f55d064bb26ea84a0fe6dd8c621b541b511982fb0c0b8c244e9521a80ea1"
]
}
Response Contents
{
"event": "login",
"success": true
}
Futures Notifications
Endpoint: /ws/futures
Accepts the following message:
Receive trade notifications by subscribing to the topic notificationApiV4
. The websocket feed will push trade level notifications to the subscriber. If topic is subscribed without being authenticated, no messages will be sent.
*** response content ***
Request Contents
{
"op": "subscribe",
"args": [
"notificationApiV4"
]
}
Response Contents
{
"topic": "notificationApiV4",
"data": [
{
"symbol": "Market Symbol (eg. BTC-PERP)",
"orderID": "internal order ID",
"side": "BUY",
"type": "76",
"txType": 0,
"price": "Order price or transacted price",
"triggerPrice": "Trade Trigger Price",
"pegPriceDeviation": "Indicate the deviation percentage. Valid for only algo orders.",
"stealth": 1,
"status": "<Refer to Status description on the left>",
"timestamp": 1624985375123,
"avgFillPrice": 35000,
"clOrderID": "<Client order ID>",
"originalOrderSize": 1,
"currentOrderSize": 1,
"filledSize": 1,
"totalFilledSize": 1,
"maker": "<Maker flag, if true indicates that trade is a maker trade>",
"remainingSize": "<Remaining size on the order>",
"time_in_force": "<Time where this order is valid>"
}
]
}
Futures User Trade Fills
Endpoint: /ws/futures
Accepts the following message:
When a trade has been transacted, this topic will send the trade information back to the subscriber.
Request Contents
{
"op": "subscribe",
"args": [
"fillsV2"
]
}
Response Contents
{
"topic": "fillsV2",
"data": [
{
"orderId": "a67c7d42-f3a0-42c5-9da0-26e0afdf5c01",
"serialId": 9311338,
"clOrderId": "_mrdngcbe1677815334917",
"type": "76",
"symbol": "BTC-PERP",
"side": "BUY",
"price": "22366.4",
"size": "1.0",
"freeAmount": "0.0111832",
"feeCurrency": "USD",
"base": "BTC-PERP",
"quote": "USD",
"maker": false,
"timestamp": 1677815334928,
"tradeId": "d3b776ff-900f-4457-9275-3abf1aeef6f5"
}
]
}
Futures All Position
Endpoint: /ws/futures
Accepts the following message:
All futures positions will be pushed periodically (per 5 secs) via this topic.
Response Content
Request Contents
{
"op": "subscribe",
"args": [
"allPositionV3"
]
}
Response Contents
{
"topic": "allPositionV3",
"data": [
{
"requestId": "<Request Id>",
"username": "<User Name>",
"marketName": "BTC-PERP-USD",
"orderType": 90,
"orderMode": 66,
"originalAmount": 0.001,
"maxPriceHeld": 0,
"pegPriceMin": 0,
"stealth": 1,
"orderID": null,
"maxStealthDisplayAmount": 0,
"sellExchangeRate": 0,
"triggerPrice": 0,
"closeOrder": true,
"liquidationInProgress": false,
"marginType": 91,
"entryPrice": 47303.404761929,
"liquidationPrice": 0,
"markedPrice": 47293.949862586,
"unrealizedProfitLoss": -0.13236859,
"totalMaintenanceMargin": 3.484381756,
"totalContracts": 14,
"isolatedLeverage": 0,
"totalFees": 0,
"totalValue": 662.115298076,
"adlScoreBucket": 2,
"orderTypeName": "TYPE_FUTURES_POSITION",
"orderModeName": "MODE_BUY",
"marginTypeName": "FUTURES_MARGIN_CROSS",
"currentLeverage": 0.02,
"avgFillPrice": 0,
"positionId": "BTC-PERP-USD|SHORT",
"positionMode": "HEDGE",
"positionDirection": "SHORT",
"settleWithNonUSDAsset": "BTC",
"takeProfitOrder": {
"orderId": "4820b20a-e41b-4273-b3ad-4b19920aeeb5",
"side": "SELL",
"triggerPrice": 31000,
"triggerUseLastPrice": false
},
"stopLossOrder": {
"orderId": "eff2b232-e2ce-4562-b0b4-0bd3713c11ec",
"side": "SELL",
"triggerPrice": 27000,
"triggerUseLastPrice": true
},
"contractSize": 0.001
},
{
"requestId": 0,
"username": "user",
"userCurrency": null,
"marketName": "LTC-PERP-USD",
"orderType": 90,
"orderMode": 83,
"originalAmount": 0.01,
"maxPriceHeld": 0,
"pegPriceMin": 0,
"stealth": 1,
"orderID": null,
"maxStealthDisplayAmount": 0,
"sellexchangeRate": 0,
"triggerPrice": 0,
"closeOrder": false,
"liquidationInProgress": false,
"marginType": 91,
"entryPrice": 69.9,
"liquidationPrice": 29684.3743872669,
"markedPrice": 70.062346733,
"unrealizedProfitLoss": -0.04870402,
"totalMaintenanceMargin": 0.319484301,
"totalContracts": 30,
"isolatedLeverage": 0,
"totalFees": 0,
"totalValue": -21.01870402,
"adlScoreBucket": 1,
"booleanVar1": false,
"orderTypeName": "TYPE_FUTURES_POSITION",
"orderModeName": "MODE_SELL",
"marginTypeName": "FUTURES_MARGIN_CROSS",
"currentLeverage": 0.1116510969,
"takeProfitOrder": null,
"stopLossOrder": null,
"settleWithNonUSDAsset": "USDT",
"positionId": "LTC-PERP-USD|SHORT",
"positionMode": "HEDGE",
"positionDirection": "SHORT",
"contractSize": 0.001
}
]
}
Futures Positions
Endpoint: /ws/futures
Accepts the following message:
Publish user's current position per 5 secs. When no symbol is specified, positions for all markets will be returned.
You will receive a record with price equals to zero when position is closed. (All-Position won't have this record)
Request Contents
{
"op": "subscribe",
"args": [
"positionsV2"
]
}
Response Contents
{
"topic": "positionsV2",
"data": [
{
"requestId": "<Request Id>",
"username": "<User Name>",
"marketName": "BTC-PERP-USD",
"orderType": 90,
"orderMode": 66,
"originalAmount": 0.001,
"maxPriceHeld": 0,
"pegPriceMin": 0,
"stealth": 1,
"orderID": null,
"maxStealthDisplayAmount": 0,
"sellExchangeRate": 0,
"triggerPrice": 0,
"closeOrder": true,
"liquidationInProgress": false,
"marginType": 91,
"entryPrice": 47303.404761929,
"liquidationPrice": 0,
"markedPrice": 47293.949862586,
"unrealizedProfitLoss": -0.13236859,
"totalMaintenanceMargin": 3.484381756,
"totalContracts": 14,
"isolatedLeverage": 0,
"totalFees": 0,
"totalValue": 662.115298076,
"adlScoreBucket": 2,
"orderTypeName": "TYPE_FUTURES_POSITION",
"orderModeName": "MODE_BUY",
"marginTypeName": "FUTURES_MARGIN_CROSS",
"currentLeverage": 0.02,
"avgFillPrice": 0,
"positionId": "BTC-PERP-USD|SHORT",
"positionMode": "HEDGE",
"positionDirection": "SHORT",
"settleWithNonUSDAsset": "BTC",
"takeProfitOrder": {
"orderId": "4820b20a-e41b-4273-b3ad-4b19920aeeb5",
"side": "SELL",
"triggerPrice": 31000,
"triggerUseLastPrice": false
},
"stopLossOrder": {
"orderId": "eff2b232-e2ce-4562-b0b4-0bd3713c11ec",
"side": "SELL",
"triggerPrice": 27000,
"triggerUseLastPrice": true
},
"contractSize": 0.001
},
{
"requestId": 0,
"username": "user",
"userCurrency": null,
"marketName": "LTC-PERP-USD",
"orderType": 90,
"orderMode": 83,
"originalAmount": 0.01,
"maxPriceHeld": 0,
"pegPriceMin": 0,
"stealth": 1,
"orderID": null,
"maxStealthDisplayAmount": 0,
"sellexchangeRate": 0,
"triggerPrice": 0,
"closeOrder": false,
"liquidationInProgress": false,
"marginType": 91,
"entryPrice": 69.9,
"liquidationPrice": 29684.3743872669,
"markedPrice": 70.062346733,
"unrealizedProfitLoss": -0.04870402,
"totalMaintenanceMargin": 0.319484301,
"totalContracts": 30,
"isolatedLeverage": 0,
"totalFees": 0,
"totalValue": -21.01870402,
"adlScoreBucket": 1,
"booleanVar1": false,
"orderTypeName": "TYPE_FUTURES_POSITION",
"orderModeName": "MODE_SELL",
"marginTypeName": "FUTURES_MARGIN_CROSS",
"currentLeverage": 0.1116510969,
"takeProfitOrder": null,
"stopLossOrder": null,
"settleWithNonUSDAsset": "USDT",
"positionId": "LTC-PERP-USD|SHORT",
"positionMode": "HEDGE",
"positionDirection": "SHORT",
"contractSize": 0.001
}
]
}
Futures Open Orders
Endpoint: /ws/futures
Accepts the following message:
Offer user's current open orders
if subscribed, websocket will responsd at the time:
after subscription
after order placed, amended, cancelled, filled (notification received)
SNAPSHOT
, otherwise, only return UPDATE
data. (check type
column) UPDATE
data, if the amount is 0, that means the order is cancelled or fully filled, otherwise, order is inserted, amended or partially filled.serialId
should be continuous. If a client receives non-continuous serialId
, it has better to subscribe again since UPDATE
datas are missed.Request Contents
{
"op": "subscribe",
"args": [
"open-order:BTC-PERP-USD"
]
}
After subscribed
{
"topic": "open-order:BTC-PERP-USD",
"serialId": 1,
"type": "SNAPSHOT",
"data": [
{
"orderID": "52ee0278-f137-4dc5-8393-a7a9ca0696e0",
"orderType": 76,
"orderMode": 66,
"orderModeName": "MODE_BUY",
"marketName": "BTC-PERP-USD",
"amount": 10,
"originalAmount": 10,
"price": 1,
"displayPrice": 1,
"triggerOrder": false,
"triggerOrderType": 0,
"triggerPrice": 0,
"vendorName": null,
"createTimestamp": 1689303771677,
"triggered": false
}
]
}
After placing an order
{
"topic": "open-order:BTC-PERP-USD",
"serialId": 2,
"type": "UPDATE",
"data": [
{
"orderID": "a4af4fdf-aaea-452e-93e5-0cd1aa70cfae",
"orderType": 76,
"orderMode": 66,
"orderModeName": "MODE_BUY",
"marketName": "BTC-PERP-USD",
"amount": 10,
"originalAmount": 10,
"price": 1,
"displayPrice": 1,
"triggerOrder": false,
"triggerOrderType": 0,
"triggerPrice": 0,
"vendorName": null,
"createTimestamp": 1689305697451,
"triggered": false
}
]
}
After amending the order price
{
"topic": "open-order:BTC-PERP-USD",
"serialId": 3,
"type": "UPDATE",
"data": [
{
"orderID": "a4af4fdf-aaea-452e-93e5-0cd1aa70cfae",
"orderType": 76,
"orderMode": 66,
"orderModeName": "MODE_BUY",
"marketName": "BTC-PERP-USD",
"amount": 10,
"originalAmount": 10,
"price": 2,
"displayPrice": 1,
"triggerOrder": false,
"triggerOrderType": 0,
"triggerPrice": 0,
"vendorName": null,
"createTimestamp": 1689305697451,
"triggered": false
}
]
}
After cancelling the order
{
"topic": "open-order:BTC-PERP-USD",
"serialId": 4,
"type": "UPDATE",
"data": [
{
"orderID": "a4af4fdf-aaea-452e-93e5-0cd1aa70cfae",
"orderType": 0,
"orderMode": 0,
"orderModeName": null,
"marketName": null,
"amount": 0,
"originalAmount": 0,
"price": 0,
"displayPrice": 0,
"triggerOrder": false,
"triggerOrderType": 0,
"triggerPrice": 0,
"vendorName": null,
"createTimestamp": 0,
"triggered": false
}
]
}
OSS Level 1 Orderbook Snapshot
Endpoint: /ws/oss/futures
The format to subscribe to will be symbol
.
The L1 orderbook will be pushed immediately when orderbook changes.
Accepts the following message:
*** response content ***
Request Contents
{
"op": "subscribe",
"args": [
"snapshotL1:BTC-PERP"
]
}
Request Contents
{
"op": "unsubscribe",
"args": [
"snapshotL1:BTC-PERP"
]
}
Response-Subscribe Contents
{
"topic": "snapshotL1:BTC-PERP",
"data": {
"bids": [
[
"28016.7",
"1.48063"
]
],
"asks": [
[
"28033.6",
"1.34133"
]
],
"type": "snapshotL1",
"symbol": "BTC-PERP",
"timestamp": 1680750154232
}
}
Futures Orderbook Incremental Updates
Endpoint: /ws/oss/futures
Subscribe to Orderbook incremental updates. The topic to subscribe to will be update
specifying the symbol (eg. update:BTC-PERP
). The first response received will be a snapshot of the current orderbook (this is indicated in the type
field) and 50 levels will be returned. Incremental updates will be sent in subsequent packets with type delta
.
Bids and asks will be sent in price
and size
tuples. The size sent will be the new updated size for the price. If a value of 0
is sent, the price should be removed from the local copy of the orderbook.
To ensure that the updates are received in sequence, seqNum
indicates the current sequence and prevSeqNum
refers to the packet before. seqNum
will always be one after the prevSeqNum
. If the sequence is out of order, you will need to unsubscribe and re-subscribe to the topic again.
Also if crossed orderbook ever occurs when the best bid higher or equal to the best ask, please unsubscribe and re-subscribe to the topic again.
Accepts the following message:
*** response content ***
Request Contents
{
"op": "subscribe",
"args": [
"update:BTC-PERP_0"
]
}
Request Contents
{
"op": "unsubscribe",
"args": [
"update:BTC-PERP_0"
]
}
Response-Subscribe Contents
{
"topic": "update:BTC-PERP_0",
"data": {
"bids": [
[
"59252.5",
"0.06865"
],
[
"59249.0",
"0.24000"
],
[
"59235.5",
"0.16073"
],
[
"59235.0",
"0.26626"
],
[
"59233.0",
"0.50000"
]
],
"asks": [
[
"59292.0",
"0.50000"
],
[
"59285.5",
"0.24000"
],
[
"59285.0",
"0.15598"
],
[
"59282.5",
"0.06829"
],
[
"59278.5",
"0.01472"
]
],
"seqNum": 628282,
"prevSeqNum": 628281,
"type": "snapshot",
"timestamp": 1565135165600,
"symbol": "BTC-PERP"
}
}
Response-Unsubscribe Contents
{
"topic": "update:BTC-PERP_0",
"data": {
"bids": [],
"asks": [
[
"59367.5",
"2.15622"
],
[
"59325.5",
"0"
]
],
"seqNum": 628283,
"prevSeqNum": 628282,
"type": "delta",
"timestamp": 1565135165600,
"symbol": "BTC-PERP"
}
}
OTC Authentication
Endpoint: /ws/otc
Accepts the following message:
Authenticate the websocket session to subscribe to authenticated websocket topics. Assume we have values as follows:
- request-nonce
: 1624985375123
- request-api
:4e9536c79f0fdd72bf04f2430982d3f61d9d76c996f0175bbba470d69d59816x
- secret
:848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx
Our subscription request will be:
Request Parameters
Below details the arguments needed to be sent in.
Generating a signature
echo -n "/ws/otc1624985375123" | openssl dgst -sha384 -hmac "848db84ac252b6726e5f6e7a711d9c96d9fd77d020151b45839a5b59c37203bx"
(stdin)=971798b32585d7e63a1c2cafd261170c56caf17ff1d32a58fc2e9842292fa8ff2dbcf4fda7b4d6aed4a737c3c2930cf1
Request Contents
{
"op": "login",
"args": [
"4e9536c79f0fdd72bf04f2430982d3f61d9d76c996f0175bbba470d69d59816x",
"1624985375123",
"971798b32585d7e63a1c2cafd261170c56caf17ff1d32a58fc2e9842292fa8ff2dbcf4fda7b4d6aed4a737c3c2930cf1"
]
}
Response Contents
{
"event": "login",
"success": true
}
OTC Quote Stream
Endpoint: /ws/otc
Accepts the following message:
Receive quote streams by subscribing to the quote
websocket. The websocket topic will constantly push new prices to the subscriber. To accept the quote, indicate the buy or sell quote Id using the /accept
API.
Request-Quote Contents
{
"op": "quote",
"symbol": "BTC-USD",
"side": "buy",
"clOrderId": "<Client order ID>",
"quantity": {
"quantity": 1,
"currency": "BTC"
}
}
Request-Unsubscribe Quote Contents
{
"op": "unsubscribe-quote",
"symbol": "BTC-USD",
"clOrderId": "<Client order ID>",
"quantity": {
"quantity": 1,
"currency": "BTC"
}
}
Request-Unsubscribe Quote Contents
{
"op": "unsubscribe-quote-all"
}
Response
{
"topic": "quote",
"buyQuoteId": "<Buy Quote Id>",
"sellQuoteId": "<Sell Quote Id>",
"clOrderId": "<Client Order Id>",
"buyQuantity": 10,
"buyUnitPrice": 47865.580838,
"buyTotalAmount": 478655.80838,
"sellQuantity": 10,
"sellUnitPrice": 47649.40351972,
"sellTotalAmount": 476494.0352,
"status": null,
"reason": null
}