Exchange Info
The base URL for endpoints described in this page of live trading API is https://api.cube.exchange/ir/v0
.
OpenAPI document for Market & User API
Market Definitions
Definitions are available as JSON and provide all of the information needed to convert between on-chain amounts and the values used on the exchange. For further details, see the Trade Api.
Market Status Field
Some trading pairs appear in multiple markets, but only a single market will be in use for a given trading pair at any given time.
Definitions appear for markets that are no longer in use; these can be used to interpret historical orders.
Markets that are currently active for trading will have a
status
of1
or2
.Markets that are no longer in use will have a
status
of3
.
Authentication Headers
The REST API uses the following HTTP headers for authentication:
x-api-key
: The API Key ID, as specified on the API settings page.Each API key has an associated access level, which is determined at the time of key creation.
Read access allows only read HTTP methods (GET, HEAD, etc.).
Write access permits all HTTP methods.
x-api-signature
: The API signature string authenticating this request.The payload to be signed is a concatenation of the byte string
cube.xyz
and the current Unix epoch timestamp in seconds, converted into an 8-byte little-endian array. The signature is the HMAC-SHA256 digest of the payload, using the secret key associated with the specified API key.Implementation notes:
The signature is base-64 encoded with the 'standard' alphabet and padding:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
.The timestamp should be encoded as an 8-byte little-endian array of bytes.
The secret key should be decoded from a hex string into a 32-byte array of bytes.
x-api-timestamp
: The timestamp used for signature generation.
Endpoints, public
GET /markets HTTP/1.1
Host:
Accept: */*
{
"result": {
"assets": [
{
"assetId": 1,
"assetType": "Crypto",
"decimals": 8,
"displayDecimals": 5,
"metadata": {
"marketCapRank": 1,
"snapshotPrice": 100000,
"supply": 21000000
},
"params": null,
"settles": true,
"sourceId": 1,
"status": 1,
"symbol": "BTC"
}
],
"sources": [
{
"addressExplorer": "https://mempool.space/address/{}",
"metadata": {
"network": "Mainnet",
"scope": "bitcoin",
"type": "mainnet"
},
"name": "bitcoin",
"sourceId": 1,
"transactionExplorer": "https://mempool.space/tx/{}"
}
],
"markets": [
{
"baseAssetId": 2,
"baseLotSize": "1000000000000000",
"baseMarketIds": [
100004,
100005
],
"feeTableId": 1,
"impliedScheme": "bsqs",
"isImplied": true,
"isPrimary": true,
"marketId": 100001,
"minOrderQuoteAmt": "1000000000000000000",
"priceBandAskPct": 500,
"priceBandBidPct": 20,
"priceDisplayDecimals": 5,
"priceTickSize": "0.00001",
"protectionPriceLevels": 1000,
"quantityTickSize": "0.001",
"quoteAssetId": 1,
"quoteLotSize": "1",
"status": 1,
"symbol": "ETHBTC"
}
],
"feeTables": [
{
"feeTableId": 1,
"feeTiers": [
{
"makerFeeRatio": 0.0004,
"priority": 1,
"takerFeeRatio": 0.0008
}
]
}
],
"marginTables": [
{
"marginTableId": 1,
"defaultLeverage": 1,
"marginTiers": [
{
"notionalValueLe": "text",
"maxLeverage": 1,
"maintenanceMarginRate": "text",
"liquidatorFee": "text"
}
]
}
]
}
}
Statistics about the price of an asset during a specific time interval. Returned as an array of unnamed values to reduce size. Fields are: [ time (in seconds since epoch), open price, high price, low price, close price, volume (in RawUnits) ] Cached frequently to improve response time; provide 'Cache-Control: no-cache' header on request to pass through.
GET /history/klines?marketId=1 HTTP/1.1
Host:
Accept: */*
{
"result": [
[
1710944100,
17263,
17509,
17247,
17459,
"23107"
],
[
1710943200,
17203,
17314,
17156,
17260,
"55426"
]
]
}
Endpoints, authentication required
Endpoints in this section require REST Authentication headers.
GET /users/check HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Accept: */*
{
"result": {
"id": "123e4567-e89b-12d3-a456-426614174000"
}
}
POST /users/apikeys HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 43
{
"accessLevel": "read",
"subaccountId": [
1,
2
]
}
{
"result": {
"accessLevel": "read",
"apiKey": "173de89b-ff98-9711-479c-09d4f54f2177",
"secret": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"subaccountId": [
1,
2
]
}
}
DELETE /users/apikeys/{api_key} HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Accept: */*
{
"result": {
"apiKey": "123e4567-e89b-12d3-a456-426614174000"
}
}
GET /users/subaccounts HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Accept: */*
{
"result": {
"ids": [
1,
2,
3
]
}
}
POST /users/subaccounts HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 50
{
"accountType": "spot",
"name": "example subaccount"
}
{
"result": {
"id": 11
}
}
GET /users/subaccount/{subaccount_id} HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Accept: */*
{
"result": {
"accountType": "spot",
"addresses": {
"101": "tb1p5gw5zm938qql65l2kqke5hx3tpmr4xkjrgy4g93qurer8eq9l2js0g6a9w",
"103": "4t2XDAGnuePMj8QUjGxr8zSVbjztwzVVZP8Su9mn1DTV",
"105": "nrceaqQdBp2PGiidq5FYe7YzsHZv9U5Yd5",
"106": "5DNHinCkxF42JUFpQGZiwof8g6SEdhYfDehRjG5ukfgZVhe6",
"107": "tltc1q7h6xgpcf7q685at7jzx74cud6a0j72yn2wsgkr",
"108": "cosmos17h6xgpcf7q685at7jzx74cud6a0j72yn06hwe5"
},
"hasOrderHistory": true,
"id": 48,
"name": "working_capital"
}
}
{"name":"subaccount new name"}
PATCH /users/subaccount/{subaccount_id} HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 30
{
"name": "subaccount new name"
}
{
"result": {
"id": 11
}
}
GET /users/subaccount/{subaccount_id}/positions HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Accept: */*
{
"result": {
"8": {
"inner": [
{
"accountingType": "asset",
"amount": "502500000",
"assetId": 1,
"pendingDeposits": "0",
"receivedAmount": "502500000"
},
{
"accountingType": "asset",
"amount": "5999780000000000000",
"assetId": 2,
"pendingDeposits": "0",
"receivedAmount": "5999780000000000000"
}
],
"name": "primary"
}
}
}
GET /users/subaccount/{subaccount_id}/transfers HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Accept: */*
{
"result": {
"8": {
"inner": [
{
"amount": "220000000",
"approved": true,
"assetId": 5,
"attemptId": 134,
"createdAt": "2023-07-30T14:30:00-05:00",
"fromAddress": "2CakzUzWpQKmx9GGexMMRTtRcjtSdjCRB68vpUKM4obk",
"fromSubaccountId": 8,
"toAddress": "8j5i8msVWLkTP2ff3bmTLK3k2m3XtW1zdJPYovon55YS",
"toSubaccountId": 9,
"txnState": "accepted"
}
],
"name": "primary account"
}
}
}
GET /users/subaccount/{subaccount_id}/deposits HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Accept: */*
{
"result": {
"8": {
"inner": [
{
"address": "bcrt1qfsf0tfcw0qvtxnm8qmktwpxpt8v0hk4rawh0n7",
"amount": "1100000000",
"assetId": 1,
"createdAt": "2023-07-30T14:30:00-05:00",
"fiatToCrypto": false,
"kytStatus": "accept",
"txnHash": "faae74ae3700cdea62f51930d489a34f3bc4ee2521a017a9bad72dbd0a5156b4",
"txnIndex": 1,
"txnState": "confirmed",
"updatedAt": "2023-07-30T14:30:00-05:00"
},
{
"address": "0x313E3566cE1Db6672287ccE000cf0c617Dc369af",
"amount": "111780000000000000",
"assetId": 2,
"createdAt": "2023-07-30T14:30:00-05:00",
"fiatToCrypto": false,
"kytStatus": "accept",
"txnHash": "0xd2f7b34100d66835565fc598bfac7469881a3db5d1a9e926813853d73a6f16c8",
"txnIndex": 0,
"txnState": "confirmed",
"updatedAt": "2023-07-30T14:30:00-05:00"
}
],
"name": "primary"
}
}
}
GET /users/subaccount/{subaccount_id}/withdrawals HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Accept: */*
{
"result": {
"8": {
"inner": [
{
"address": "bcrt1qfsf0tfcw0qvtxnm8qmktwpxpt8v0hk4rawh0n7",
"amount": "12000000",
"approved": true,
"assetId": 1,
"attemptId": 112,
"createdAt": "2023-07-30T14:30:00-05:00",
"kytStatus": "accept",
"txnHash": "faae74ae3700cdea62f51930d489a34f3bc4ee2521a017a9bad72dbd0a5156b4",
"txnIndex": 1,
"txnState": "confirmed",
"updatedAt": "2023-07-30T14:30:00-05:00"
},
{
"address": "0x313E3566cE1Db6672287ccE000cf0c617Dc369af",
"amount": "11178000000000000000",
"approved": true,
"assetId": 2,
"attemptId": 234,
"createdAt": "2023-07-30T14:30:00-05:00",
"kytStatus": "accept",
"txnHash": "0xd2f7b34100d66835565fc598bfac7469881a3db5d1a9e926813853d73a6f16c8",
"txnIndex": 0,
"txnState": "confirmed",
"updatedAt": "2023-07-30T14:30:00-05:00"
}
],
"name": "primary"
}
}
}
Returns the most recent orders where created_at < created_before
. If null, returns the most recent orders.
The maximum number of orders to return. If null, defaults to 100. The maximum is 1000.
GET /users/subaccount/{subaccount_id}/orders HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Accept: */*
{
"result": {
"name": "primary",
"orders": [
{
"cancelOnDisconnect": false,
"clientOrderId": 1720791493653,
"createdAt": 1720791493673997000,
"filledAt": 1720933004211574000,
"filledTotal": {
"baseAmount": "3000000",
"feeAmount": "0",
"feeAssetId": 1,
"filledAt": 1720933004211574000,
"price": 600000,
"quantity": 3000,
"quoteAmount": "1800000000"
},
"fills": [
{
"baseAmount": "3000000",
"baseSettled": true,
"feeAmount": "0",
"feeAssetId": 1,
"filledAt": 1720933004211574000,
"isAggressor": true,
"price": 600000,
"quantity": 3000,
"quoteAmount": "1800000000",
"quoteSettled": true,
"tradeId": 620011
}
],
"marketId": 100004,
"orderId": 610001,
"orderType": 0,
"postOnly": false,
"price": 600000,
"qty": 3000,
"selfTradePrevention": 0,
"side": "Bid",
"status": "filled",
"timeInForce": 1
}
]
}
}
GET /users/subaccount/{subaccount_id}/fills HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Accept: */*
{
"result": {
"fills": [
{
"aggressingSide": "Ask",
"baseAmount": "3000000",
"feeAmount": "0",
"feeAssetId": 1,
"filledAt": 1720933004211574000,
"marketId": 100004,
"orderId": 610001,
"price": 700000,
"quantity": 3000,
"quoteAmount": "2100000000",
"side": "Bid",
"tradeId": 620011
}
],
"name": "primary"
}
}
POST /users/fee-estimates HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 100
{
"marketId": 100086,
"postOnly": "Disabled",
"price": 14332,
"quantity": 10,
"side": "Bid",
"subaccountId": 42
}
{
"result": {
"estimatedFees": [
{
"amount": "1200",
"assetId": 5,
"direction": "fee",
"name": "tradeFee"
},
{
"amount": "100000",
"assetId": 5,
"direction": "rebate",
"name": "impliedMatchFee"
}
]
}
}
GET /users/address HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Accept: */*
{
"result": {
"addresses": [
{
"activeSince": "2024-06-14T20:33:17.79384Z",
"address": "CNf2sYNM8iH4aGtDSvmRRWEQorVvG3cMWzumtQo7Q8h8",
"approvedAt": "2024-06-13T20:33:17.79384Z",
"assetId": 5,
"createdAt": "2024-06-13T20:32:17.79384Z",
"id": "b4054981-600b-4ae1-858e-01f65f09dd60",
"name": "My Address 1",
"sourceId": 3,
"status": "active"
}
],
"settings": {
"whitelistStatus": "enabled",
"whitelisted": true
}
}
}
GET /users/address/settings HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Accept: */*
{
"result": {
"whitelistStatus": "enabled",
"whitelisted": true
}
}
The subaccount to withdraw from.
The asset to withdraw. The network is determined by the asset ID.
The amount to withdraw. This is denominated in the smallest unit of the asset (e.g. satoshis for BTC, wei for ETH, lamports for SOL). The amount must be greater than the dust limit for the asset.
The destination address for the withdrawal.
Base-64 encoded cube_ov_utils::ov_schema::PublicKey
Base-64 encoded signature of this withdrawal request
POST /users/withdraw HTTP/1.1
Host:
x-api-key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 116
{
"amount": "220000000000000",
"assetId": 2,
"destination": "0x403244EcfafF17c31e39fc67848d61d9b6637Ee2",
"subaccountId": 8
}
{
"result": {
"approved": true,
"status": "accept"
}
}
Last updated