General Info
General API Information
- The base endpoint is: https://fapi.triunits.com
- All endpoints return either a JSON object or array.
- Data is returned in ascending order. Oldest first, newest last.
- All time and timestamp related fields are in milliseconds.
Intervals
m -> minutes; h -> hours; d -> days; w -> weeks; M -> months
- 1m
- 3m
- 5m
- 15m
- 30m
- 1h
- 2h
- 4h
- 6h
- 8h
- 12h
- 1d
- 3d
- 1w
- 1M
Filters
PRICE_FILTER
ExchangeInfo Format:
{
"filterType": "PRICE_FILTER",
"minPrice": "0.00000100",
"maxPrice": "100000.00000000",
"tickSize": "0.00000100"
}
The PRICE_FILTER defines the price rules for a symbol. There are 3 parts:
- minPrice defines the minimum price/stopPrice allowed; disabled on minPrice == 0.
- maxPrice defines the maximum price/stopPrice allowed; disabled on maxPrice == 0.
- tickSize defines the intervals that a price/stopPrice can be increased/decreased by; disabled on tickSize == 0.
Any of the above variables can be set to 0, which disables that rule in the price filter. In order to pass the price filter, the following must be true for price/stopPrice of the enabled rules:
- price >= minPrice
- price <= maxPrice
- (price-minPrice) % tickSize == 0
PERCENT_PRICE
ExchangeInfo Format:
{
"filterType": "PERCENT_PRICE",
"multiplierUp": "1.3000",
"multiplierDown": "0.7000",
"avgPriceMins": 5
}
The PERCENT_PRICE
filter defines valid range for a price based on the average of the previous trades. avgPriceMins
is the number of minutes the average price is calculated over. 0 means the last price is used.
In order to pass the percent price
, the following must be true for price:
price <= weightedAveragePrice
* multiplierUp
price >= weightedAveragePrice
* multiplierDown
LOT_SIZE
ExchangeInfo format:
{
"filterType": "LOT_SIZE",
"minQty": "0.00100000",
"maxQty": "100000.00000000",
"stepSize": "0.00100000"
}
The LOT_SIZE filter defines the quantity (aka "lots" in auction terms) rules for a symbol. There are 3 parts:
- minQty defines the minimum quantity/icebergQty allowed.
- maxQty defines the maximum quantity/icebergQty allowed.
stepSize defines the intervals that a quantity/icebergQty can be increased/decreased by. In order to pass the lot size, the following must be true for quantity/icebergQty:
quantity >= minQty
quantity <= maxQty
(quantity-minQty) % stepSize == 0
MIN_NOTIONAL
ExchangeInfo Format:
{
"filterType": "MIN_NOTIONAL",
"minNotional": "0.00100000",
"applyToMarket": true,
"avgPriceMins": 5
}
The MIN_NOTIONAL filter defines the minimum notional value allowed for an order on a symbol. An order's notional value is the price * quantity. If the order is an Algo order (e.g. STOP_LOSS_LIMIT), then the notional value of the stopPrice * quantity will also be evaluated. If the order is an Iceberg Order, then the notional value of the price * icebergQty will also be evaluated. applyToMarket determines whether or not the MIN_NOTIONAL filter will also be applied to MARKET orders. Since MARKET orders have no price, the average price is used over the last avgPriceMins minutes. avgPriceMins is the number of minutes the average price is calculated over. 0 means the last price is used.
Wallet Endpoints
System Status (System)
Response:
{
"status": 0, // 0: normal,1:system maintenance
"msg": "normal" // normal or system maintenance
}
This endpoint fetch the system status.
HTTP Request
GET /spot/systemStatus
Market Data Endpoints
Check Server Time
Response:
{
"serverTime": 1609577382447
}
Test connectivity to the Rest API and get the current server time.
HTTP Request
GET /spot/time
Exchange Information
Response:
{
"timezone": "UTC",
"serverTime": 1565246363776,
"rateLimits": [
{
//These are defined in the `ENUM definitions` section under `Rate Limiters (rateLimitType)`.
//All limits are optional
}
],
"exchangeFilters": [
//These are the defined filters in the `Filters` section.
//All filters are optional.
],
"symbols": [
{
"symbol": "ETHBTC",
"status": "TRADING",
"baseAsset": "ETH",
"baseAssetPrecision": 8,
"quoteAsset": "BTC",
"quotePrecision": 8,
"quoteAssetPrecision": 8,
"orderTypes": [
"LIMIT",
"LIMIT_MAKER",
"MARKET",
"STOP_LOSS",
"STOP_LOSS_LIMIT",
"TAKE_PROFIT",
"TAKE_PROFIT_LIMIT"
],
"icebergAllowed": true,
"ocoAllowed": true,
"isSpotTradingAllowed": true,
"isMarginTradingAllowed": true,
"filters": [
//These are defined in the Filters section.
//All filters are optional
],
"permissions": ["SPOT", "MARGIN"]
}
]
}
Current exchange trading rules and symbol information
HTTP Request
GET /spot/exchangeInfo
Assets
Response:
[
{
"id": "512",
"assetCode": "INJ",
"assetName": "Injective Protocol",
"unit": "",
"commissionRate": 0,
"freeAuditWithdrawAmt": 0,
"freeUserChargeAmount": 1000000,
"createTime": 1603080237000,
"test": 0,
"gas": null,
"isLegalMoney": false,
"reconciliationAmount": 0,
"seqNum": "0",
"chineseName": "Injective Protocol",
"cnLink": "",
"enLink": "",
"logoUrl": "https://triunits.com/icons/INJ.png",
"fullLogoUrl": "https://triunits.com/icons/INJ.png",
"supportMarket": null,
"feeReferenceAsset": null,
"feeRate": null,
"feeDigit": 8,
"assetDigit": 8,
"trading": true,
"tags": ["defi", "pos", "BSC", "Launchpad", "bnbchain"],
"plateType": "MAINWEB",
"etf": false,
"isLedgerOnly": false,
"delisted": false
}
]
Current exchange trading rules and symbol information
HTTP Request
GET /v1/spot/assets
Order Book
Response:
{
"timestamp": 1660733030414,
"bids": [
[
"4.00000000", // PRICE
"431.00000000" // QTY
]
],
"asks": [["4.00000200", "12.00000000"]]
}
Exchange Order Book
HTTP Request
GET /v1/spot/orderbook/:symbol
Limits
5, 10, 20, 50, 100, 500, 1000, 5000
URL Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | E.g. /orderbook/BTC_USDT or, /orderbook/BTCUSDT |
limit | INT | NO | Default 500; max 5000 |
Recent Trades List
[
{
"base_volume": "71.60000000",
"price": "0.93060000",
"quote_volume": "66.63096000",
"timestamp": 1660731757959,
"type": "sell"
}
]
Get recent trades.
HTTP Request
GET /v1/spot/trades/:symbol
URL Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | E.g. /trades/BTC_USDT or, /trades/BTCUSDT |
limit | INT | NO | Default 500; max 5000 |
Kline/Candlestick Data
Response:
[
[
1499040000000, // Open time
"0.01634790", // Open
"0.80000000", // High
"0.01575800", // Low
"0.01577100", // Close
"148976.11427815", // Volume
1499644799999, // Close time
"2434.19055334", // Quote asset volume
308, // Number of trades
"1756.87402397", // Taker buy base asset volume
"28.46694368", // Taker buy quote asset volume
"17928899.62484339" // Ignore.
]
]
Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
HTTP Request
GET /spot/klines
URL Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
interval | ENUM | NO | |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 500; max 5000 |
Full Market Ticker
Response:
{
"1INCHBTC": {
"priceChange": "0.00000004",
"priceChangePercent": "0.116",
"weightedAvgPrice": "0.00003439",
"prevClosePrice": "0.00003440",
"lastPrice": "0.00003441",
"lastQty": "43.50000000",
"bidPrice": "0.00003435",
"askPrice": "0.00003440",
"openPrice": "0.00003437",
"highPrice": "0.00003500",
"lowPrice": "0.00003396",
"volume": "134350.10000000",
"quoteVolume": "4.62030682",
"openTime": 1660646195623,
"closeTime": 1660732595623,
"firstId": 9414995,
"lastId": 9418189,
"count": 3195
},
}
24 hour rolling window price change statistics. Careful when accessing this with no symbol.
HTTP Request
GET /v1/spot/ticker
24hr Ticker Price Change Statistics
Response:
{
"symbol": "DOTSBTC",
"priceChange": "-94.99999800",
"priceChangePercent": "-95.960",
"weightedAvgPrice": "0.29628482",
"prevClosePrice": "0.10002000",
"lastPrice": "4.00000200",
"lastQty": "200.00000000",
"bidPrice": "4.00000000",
"askPrice": "4.00000200",
"openPrice": "99.00000000",
"highPrice": "100.00000000",
"lowPrice": "0.10000000",
"volume": "8913.30000000",
"quoteVolume": "15.30000000",
"openTime": 1499783499040,
"closeTime": 1499869899040,
"firstId": 28385, // First tradeId
"lastId": 28460, // Last tradeId
"count": 76 // Trade count
}
OR
[
{
"symbol": "DOTSBTC",
"priceChange": "-94.99999800",
"priceChangePercent": "-95.960",
"weightedAvgPrice": "0.29628482",
"prevClosePrice": "0.10002000",
"lastPrice": "4.00000200",
"lastQty": "200.00000000",
"bidPrice": "4.00000000",
"askPrice": "4.00000200",
"openPrice": "99.00000000",
"highPrice": "100.00000000",
"lowPrice": "0.10000000",
"volume": "8913.30000000",
"quoteVolume": "15.30000000",
"openTime": 1499783499040,
"closeTime": 1499869899040,
"firstId": 28385, // First tradeId
"lastId": 28460, // Last tradeId
"count": 76 // Trade count
}
]
24 hour rolling window price change statistics. Careful when accessing this with no symbol.
HTTP Request
GET /spot/ticker/24hr
URL Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES |
Symbol Price Ticker
Response:
{
"symbol": "LTCBTC",
"price": "4.00000200"
}
OR
[
{
"symbol": "LTCBTC",
"price": "4.00000200"
},
{
"symbol": "ETHBTC",
"price": "0.07946600"
}
]
Latest price for a symbol or symbols.
HTTP Endpoint
GET /spot/ticker/price
URL Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES |
Symbol Order Book Ticker
Response:
{
"symbol": "LTCBTC",
"bidPrice": "4.00000000",
"bidQty": "431.00000000",
"askPrice": "4.00000200",
"askQty": "9.00000000"
}
OR
[
{
"symbol": "LTCBTC",
"bidPrice": "4.00000000",
"bidQty": "431.00000000",
"askPrice": "4.00000200",
"askQty": "9.00000000"
},
{
"symbol": "ETHBTC",
"bidPrice": "0.07946700",
"bidQty": "9.00000000",
"askPrice": "100000.00000000",
"askQty": "1000.00000000"
}
]
Best price/qty on the order book for a symbol or symbols.
HTTP Endpoint
GET /spot/ticker/bookTicker
URL Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES |
Futures Market Endpoints
Futures Test Connectivity
Response:
{}
Test connectivity to the Rest API.
HTTP Request
GET /fapi/ping
Futures Check Server Time
Response:
{
"serverTime": 1499827319559
}
Test connectivity to the Rest API.
HTTP Request
GET /fapi/time
Futures Exchange Information
Response:
{
"exchangeFilters": [],
"rateLimits": [
{
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"rateLimitType": "REQUEST_WEIGHT"
},
{
"interval": "MINUTE",
"intervalNum": 1,
"limit": 1200,
"rateLimitType": "ORDERS"
}
],
"serverTime": 1565613908500,
"symbols": [
{
"symbol": "BLZUSDT",
"pair": "BLZUSDT",
"contractType": "PERPETUAL",
"deliveryDate": 4133404800000,
"onboardDate": 1598252400000,
"status": "TRADING",
"maintMarginPercent": "2.5000", // ignore
"requiredMarginPercent": "5.0000", // ignore
"baseAsset": "BLZ",
"quoteAsset": "USDT",
"marginAsset": "USDT",
"pricePrecision": 5, // please do not use it as tickSize
"quantityPrecision": 0, // please do not use it as stepSize
"baseAssetPrecision": 8,
"quotePrecision": 8,
"underlyingType": "COIN",
"underlyingSubType": ["STORAGE"],
"settlePlan": 0,
"triggerProtect": "0.15", // threshold for algo order with "priceProtect"
"filters": [
{
"filterType": "PRICE_FILTER",
"maxPrice": "300",
"minPrice": "0.0001",
"tickSize": "0.0001"
},
{
"filterType": "LOT_SIZE",
"maxQty": "10000000",
"minQty": "1",
"stepSize": "1"
},
{
"filterType": "MARKET_LOT_SIZE",
"maxQty": "590119",
"minQty": "1",
"stepSize": "1"
},
{
"filterType": "MAX_NUM_ORDERS",
"limit": 200
},
{
"filterType": "MAX_NUM_ALGO_ORDERS",
"limit": 100
},
{
"filterType": "MIN_NOTIONAL",
"notional": "1",
},
{
"filterType": "PERCENT_PRICE",
"multiplierUp": "1.1500",
"multiplierDown": "0.8500",
"multiplierDecimal": 4
}
],
"OrderType": [
"LIMIT",
"MARKET",
"STOP",
"STOP_MARKET",
"TAKE_PROFIT",
"TAKE_PROFIT_MARKET",
"TRAILING_STOP_MARKET"
],
"timeInForce": [
"GTC",
"IOC",
"FOK",
"GTX"
]
}
],
"timezone": "UTC"
}
Current exchange trading rules and symbol information
HTTP Request
GET /fapi/exchangeInfo
Futures Order Book
Response:
{
"lastUpdateId": 1027024,
"E": 1589436922972, // Message output time
"T": 1589436922959, // Transaction time
"bids": [
[
"4.00000000", // PRICE
"431.00000000" // QTY
]
],
"asks": [
[
"4.00000200",
"12.00000000"
]
]
}
Test connectivity to the Rest API.
HTTP Request
GET /fapi/depth
URL Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
limit | INT | NO | Default 500; Valid limits:[5, 10, 20, 50, 100, 500, 1000] |
Futures Recent Trade List
Response:
{
"lastUpdateId": 1027024,
"E": 1589436922972, // Message output time
"T": 1589436922959, // Transaction time
"bids": [
[
"4.00000000", // PRICE
"431.00000000" // QTY
]
],
"asks": [
[
"4.00000200",
"12.00000000"
]
]
}
Test connectivity to the Rest API.
HTTP Request
GET /fapi/trades
URL Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
limit | INT | NO | Default 500; Max: 1000. |
Futures Kline/Candlestick Data
Response:
[
[
1499040000000, // Open time
"0.01634790", // Open
"0.80000000", // High
"0.01575800", // Low
"0.01577100", // Close
"148976.11427815", // Volume
1499644799999, // Close time
"2434.19055334", // Quote asset volume
308, // Number of trades
"1756.87402397", // Taker buy base asset volume
"28.46694368", // Taker buy quote asset volume
"17928899.62484339" // Ignore.
]
]
Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
HTTP Request
GET /fapi/klines
URL Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
interval | ENUM | NO | |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 500; max 5000 |
Errors
The Triunits API uses the following error codes:
Error Code | Meaning |
---|---|
400 | Bad Request -- Your request is invalid. |
401 | Unauthorized -- Your API key is wrong. |
403 | Forbidden -- You are not allowed to access this resource. |
404 | Not Found -- The specified resource could not be found. |
405 | Method Not Allowed -- You tried to access a resource with an invalid method. |
406 | Not Acceptable -- You requested a format that isn't json. |
429 | Too Many Requests -- You're requesting too many calls! Slow down! |
500 | Internal Server Error -- We had a problem with our server. Try again later. |
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. |