Contract API
Base Info
The base url
market-api
https://api-futures.trubit.com/market/api/v1
trade-api
https://api-futures.trubit.com/trade/api/v1
market-websocket
wss://api-futures.trubit.com/ws/market
trade-websocket
wss://api-futures.trubit.com/ws/trade
Time zone
The time zone for all times is UTC+0
WebSocket Overview
WebSocket is a new protocol for HTML5, which enables full-duplex communication between the client and the server, allowing data to travel in both directions quickly. The client and server connections can be established through a simple handshake, and the server can actively push information to the client according to the business rules. The advantages are as follows:
When the client and the server perform data transmission, the request header information is relatively small, about 2 bytes.
Both the client and the server can actively send data to the other party.
There is no need to create TCP requests and destroy multiple times, saving bandwidth and server resources.
Market Endpoint
Contract info
Contract info
Exchange trading rules and symbol information
Limit:
Speed limit: 1 times/second, Speed limit rule: IP
Request Url:
Parameters:
------------
------------
------------
------------
----
Response:
symbol
string
XRPUSDT
Contract name
lotSize
float
1.0
Defines the minimum quantity allowed
tick
float
0.00001
Minimal price value
type
string
USDT
Contract type, PERP => Perpetual Contract.
Example:
Klines
Klines
Obtain K line by from and step
Limit:
Speed limit: 15 times/1min, Speed limit rule: IP
Request URL:
Parameters:
symbol
string
YES
--
The contract symbol
type
string
YES
--
Interval of the kline. Identifiable values: 1M, 3M, 5M, 10M, 15M, 30M, 1H, 2H, 4H, 6H, 8H, 12H, D, 3D, W, MTH
from
integer
NO
0
Start from of K line, 0 means from the latest one
step
integer
NO
--
The number of K line, equal or less than 1500
Response:
[0]
string
26435.5
Close Price
[1]
string
26435.5
High Price
[2]
string
1686905040
*1000 timestamp(ms)
[3]
string
26435.5
Low Price
[4]
string
26435.5
Open Price
[6]
string
7.08
Volume eg:BTCUSDT The unit is BTC
[7]
string
181074.0
Turnover eg:BTCUSDT The unit is USDT
Example:
Klines By Time
Klines By Time
Obtain K line by time and step
Limit:
Speed limit: 15 times/1min, Speed limit rule: IP
Request URL:
Parameters:
symbol
string
YES
--
The contract symbol
type
string
YES
--
Interval of the kline. Identifiable values: 1M, 3M, 5M, 10M, 15M, 30M, 1H, 2H, 4H, 6H, 8H, 12H, D, 3D, W, MTH
from
integer
NO
currentTimeMillis
Milli seconds of K line keyTime, query from the latest one if not provided
step
integer
YES
--
The number of K line, equal or less than 1500
Response:
[0]
string
26435.5
Close Price
[1]
string
26435.5
High Price
[2]
string
1686905040
*1000 timestamp(ms)
[3]
string
26435.5
Low Price
[4]
string
26435.5
Open Price
[6]
string
7.08
Volume eg:BTCUSDT The unit is BTC
[7]
string
181074.0
Turnover eg:BTCUSDT The unit is USDT
Example:
Index
Index
Index price of underlying asset
Limit:
Speed limit: 10 times/second, Speed limit rule: IP
Request Url:
Parameters:
symbols
string
NO
--
The contract symbol, multiple symbols separated by ',', eg: BTCUSDT,ETHUSDT
Response:
symbol
string
BTCUSDT
The contract symbol
price
float
8342.73
The index price of the underlying
time
long
1686196441142
The time of the underlying
Example:
Last Price
Last Price
Query last price of instrument(s)
Limit:
Speed limit: 1 times/second, Speed limit rule: IP
Request Url:
Parameters:
symbols
string
NO
--
The contract symbol, multiple symbols separated by ',', eg: BTCUSDT,ETHUSDT
Response:
symbol
string
BTCUSDT
The contract symbol
price
float
8342.73
The last price
time
long
1686196441142
The time
Example:
Mark Price
Mark Price
Query mark price of instrument(s)
Limit:
Speed limit: 10 times/second, Speed limit rule: IP
Request Url:
Parameters:
symbols
string
NO
``
The contract symbol, multiple symbols separated by ',', eg: BTCUSDT,ETHUSDT
Response:
symbol
string
BTCUSDT
The contract symbol
price
float
8342.73
The mark price
time
long
1686196441142
The time
Example:
Funding Rate
Funding Rate
Obtain funding rate of instrument
Limit:
Speed limit: 5 times/second, Speed limit rule: IP
Request Url:
Parameters:
symbols
string
NO
The contract symbol, multiple symbols separated by ',', eg: BTCUSDT,ETHUSDT
Response:
symbol
string
BTCUSDT
The contract symbol
rate
double
0.0001
Funding rate
date
string
2023-06-08T07:00:00.000+00:00
Time
time
long
1686196441142
Timestamp
Example:
Depth
Depth
Query market depth Snapshot & trades of instrument
Limit:
Speed limit: 10 times/second, Speed limit rule: IP
Request Url:
Parameters:
symbol
string
YES
--
The contract symbol to be retrieved
level
integer
NO
20
The number(5/10/20) of entries returned for bids and asks
Response:
price
double
26418.5
Price
qty
double
18873.0
Positive integer, 1Qty=1USDT
count
int
1
Order count
iceCount
int
1
Ice Count
Example:
trades
trades
Retrieve the latest trades that have occurred for a specific contract.
Limit:
Speed limit: 10 times/second, Speed limit rule: IP
Request URL:
Parameters:
symbol
string
YES
--
The contract symbol
sequence
string
NO
--
Sequence of last trade id, retrieve all trades if value is null
Response:
id
string
1686213904404000035
Trade id
symbol
string
BTCUSDT
The contract symbol
price
double
1295.0
Price
qty
double
1295.0
The quantity traded
buyActive
boolean
true
True is the buyer's active order, false is the seller's active order
tms
long
1537797044116
timestamp (ms)
Example:
Trade Statistics in latest 24 hours
Trade Statistics in latest 24 hours
Trade Statistics in latest 24 hours
Limit:
Speed limit: 10 times/second, Speed limit rule: IP
Request URL:
Parameters:
symbols
string
YES
--
The contract symbol, multiple symbols separated by ',', eg: BTCUSDT,ETHUSDT
Response:
'symbol'
string
BTCUSDT
The contract symbol
'lastPrice'
double
BTCUSDT
The contract symbol
'maxPrice'
double
26420.9
Max price
'minPrice'
double
25713.4
Min price
'priceChange'
double
-142.0
Price change
'priceChangeRatio'
double
-0.005437842019200944
Price change ratio
'volume'
double
6.5697459E7
eg:BTCUSDT The unit is BTC
'turnover'
double
2483.5865212475437
eg:BTCUSDT The unit is USDT
Example:
Open Position In Exchange
Open Position In Exchange
Total Open Position In Exchange
Limit:
Speed limit: 5 times/second, Speed limit rule: IP
Request URL:
Parameters:
symbol
string
YES
--
The contract symbol
Response:
'symbol'
string
BTCUSDT
The contract symbol
'date'
double
2023-06-19T02:37:53.617+00:00
Time
'qty'
double
1084388.0
eg:BTCUSDT The unit is USDT
'value'
double
41.035743951380205
eg:BTCUSDT The unit is BTC
Example:
Public Websocket Endpoints
Receiving data requires an event subscription
Kline
Kline
Parameters:
op
string
YES
--
subscribe/unsubscribe
key
string
YES
--
The contract symbol
type
string
YES
--
1M, 3M, 5M, 10M, 15M, 30M, 1H, 2H, 4H, 6H, 8H, 12H, D, 3D, W, MTH
channel
string
YES
--
Channel
Example:
Response:
[0]
string
26435.5
Close Price
[1]
string
26435.5
High Price
[2]
string
1686905040
*1000 timestamp(ms)
[3]
string
26435.5
Low Price
[4]
string
26435.5
Open Price
[6]
string
7.08
Volume eg:BTCUSDT The unit is BTC
[7]
string
181074.0
Turnover eg:BTCUSDT The unit is USDT
Example:
Depth
Depth
Parameters:
op
string
YES
--
subscribe/unsubscribe
key
string
YES
--
The contract symbol
channel
string
YES
--
Channel
### Example:
```json
{
"op": "subscribe",
"key": "BTCUSDT",
"channel": "depthUpdate"
}
```
### Response:
Name
Type
Example
Description
------------