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 of 1 or 2.
  • Markets that are no longer in use will have a status of 3.

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.

API Reference

Cube Iridium HTTP API

Version 0.1.0

Authentication

ApiKey

apiKey

The API Key ID as specified in the API settings page.

Each API key has a corresponding access level that is set when the key is created.
- Read access only allows access to read HTTP methods (GET, HEAD, etc.).
- Write access allows access to all HTTP methods.

in: header

ApiSignature

apiKey

The API signature string authenticating this request.

The payload to be signed is the 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 8-byte little-endian (array of bytes)
- The secret key should be decoded from a hex string into a 32-byte array of
bytes

in: header

ApiTimestamp

apiKey

The timestamp used for signature generation.

in: header

Endpoints, public

GET
/markets

Fetch all asset, market, and source definitions

Request Example

cURL

curl --request GET \
  --url '/markets'
GET
/history/klines

Aggregated historical price data (klines)

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.

Parameters

marketId

queryRequiredinteger

interval

queryOptionalstring

startTime

queryOptionalinteger

endTime

queryOptionalinteger

limit

queryOptionalinteger

Request Example

cURL

curl --request GET \
  --url '/history/klines?marketId=%3CmarketId%3E'

Endpoints, authentication required

Endpoints in this section require REST Authentication headers.

GET
/users/check

GET /users/check

ApiKeyApiSignatureApiTimestamp

Request Example

cURL

curl --request GET \
  --url '/users/check' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
POST
/users/apikeys

POST /users/apikeys

ApiKeyApiSignatureApiTimestamp
Request Body
Required
application/json

accessLevel

stringRequired
Enum read, write

items

integerint64

Request Example

application/json

cURL

curl --request POST \
  --url '/users/apikeys' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>' \
  --header 'Content-Type: application/json' \
  --data '{
  "accessLevel": "read",
  "subaccountId": [
    1,
    2
  ]
}'
DELETE
/users/apikeys/{api_key}

DELETE /users/apikeys/{api_key}

ApiKeyApiSignatureApiTimestamp

Request Example

cURL

curl --request DELETE \
  --url '/users/apikeys/<api_key>' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
GET
/users/subaccounts

GET /users/subaccounts

ApiKeyApiSignatureApiTimestamp

Request Example

cURL

curl --request GET \
  --url '/users/subaccounts' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
POST
/users/subaccounts

POST /users/subaccounts

ApiKeyApiSignatureApiTimestamp
Request Body
Required
application/json

name

stringRequired

accountType

stringRequired
Enum spot, margin

Request Example

application/json

cURL

curl --request POST \
  --url '/users/subaccounts' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>' \
  --header 'Content-Type: application/json' \
  --data '{
  "accountType": "spot",
  "name": "example subaccount"
}'
GET
/users/subaccount/{subaccount_id}

GET /users/subaccount/{subaccount_id}

ApiKeyApiSignatureApiTimestamp
Parameters

subaccount_id

pathRequiredinteger

Request Example

cURL

curl --request GET \
  --url '/users/subaccount/<subaccount_id>' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
PATCH
/users/subaccount/{subaccount_id}

PATCH /users/subaccount/{subaccount_id}

ApiKeyApiSignatureApiTimestamp
Request Body
Required
application/json

name

stringRequired

contractId

integerRequiredint32

leverage

integerRequireduint16

Request Example

application/json

cURL

curl --request PATCH \
  --url '/users/subaccount/<subaccount_id>' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "subaccount new name"
}'
GET
/users/subaccount/{subaccount_id}/positions

GET /users/subaccount/{subaccount_id}/positions

ApiKeyApiSignatureApiTimestamp
Parameters

subaccount_id

pathRequiredinteger

Request Example

cURL

curl --request GET \
  --url '/users/subaccount/<subaccount_id>/positions' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
GET
/users/subaccount/{subaccount_id}/transactions

GET /users/subaccount/{subaccount_id}/transactions

ApiKeyApiSignatureApiTimestamp
Parameters

subaccount_id

pathRequiredinteger

Request Example

cURL

curl --request GET \
  --url '/users/subaccount/<subaccount_id>/transactions' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
GET
/users/subaccount/{subaccount_id}/transfers

GET /users/subaccount/{subaccount_id}/transfers

ApiKeyApiSignatureApiTimestamp
Parameters

subaccount_id

pathRequiredinteger

Request Example

cURL

curl --request GET \
  --url '/users/subaccount/<subaccount_id>/transfers' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
GET
/users/subaccount/{subaccount_id}/deposits

GET /users/subaccount/{subaccount_id}/deposits

ApiKeyApiSignatureApiTimestamp
Parameters

subaccount_id

pathRequiredinteger

Request Example

cURL

curl --request GET \
  --url '/users/subaccount/<subaccount_id>/deposits' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
GET
/users/subaccount/{subaccount_id}/withdrawals

GET /users/subaccount/{subaccount_id}/withdrawals

ApiKeyApiSignatureApiTimestamp
Parameters

subaccount_id

pathRequiredinteger

Request Example

cURL

curl --request GET \
  --url '/users/subaccount/<subaccount_id>/withdrawals' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
GET
/users/subaccount/{subaccount_id}/orders

GET /users/subaccount/{subaccount_id}/orders

ApiKeyApiSignatureApiTimestamp
Parameters

subaccount_id

pathRequiredinteger

createdBefore

queryOptionalinteger

Returns the most recent orders where `created_at < created_before`. If null, returns the most recent orders.

limit

queryOptionalinteger

The maximum number of orders to return. If null, defaults to 100. The maximum is 1000.

Request Example

cURL

curl --request GET \
  --url '/users/subaccount/<subaccount_id>/orders' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
GET
/users/subaccount/{subaccount_id}/fills

GET /users/subaccount/{subaccount_id}/fills

ApiKeyApiSignatureApiTimestamp
Parameters

subaccount_id

pathRequiredinteger

startTime

queryOptionalinteger

endTime

queryOptionalinteger

marketIds

queryOptionalstring

orderIds

queryOptionalstring

Request Example

cURL

curl --request GET \
  --url '/users/subaccount/<subaccount_id>/fills' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
POST
/users/fee-estimates

POST /users/fee-estimates

ApiKeyApiSignatureApiTimestamp
Request Body
Required
application/json

marketId

integerRequiredint32

subaccountId

integerRequiredint64

side

stringRequired
Enum Bid, Ask

postOnly

stringRequired
Enum Disabled, Enabled

quantity

integeruint64Nullable

quoteQuantity

integeruint64Nullable

price

integerRequireduint64

Request Example

application/json

cURL

curl --request POST \
  --url '/users/fee-estimates' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>' \
  --header 'Content-Type: application/json' \
  --data '{
  "marketId": 100086,
  "postOnly": "Disabled",
  "price": 14332,
  "quantity": 10,
  "side": "Bid",
  "subaccountId": 42
}'
GET
/users/address

GET /users/address

ApiKeyApiSignatureApiTimestamp
Parameters

sourceIds

queryOptionalstring

names

queryOptionalstring

Request Example

cURL

curl --request GET \
  --url '/users/address' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
GET
/users/address/settings

GET /users/address/settings

ApiKeyApiSignatureApiTimestamp

Request Example

cURL

curl --request GET \
  --url '/users/address/settings' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>'
POST
/users/withdraw

POST /users/withdraw

ApiKeyApiSignatureApiTimestamp
Request Body
Required
application/json

subaccountId

integerRequireduint64

The subaccount to withdraw from.

assetId

integerRequireduint64

The asset to withdraw. The network is determined by the asset ID.

amount

integerRequireduint128

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.

destination

stringRequired

The destination address for the withdrawal.

timestamp

integeruint64

verificationKey

string

Base-64 encoded `cube_ov_utils::ov_schema::PublicKey`

signature

string

Base-64 encoded signature of this withdrawal request

Request Example

application/json

cURL

curl --request POST \
  --url '/users/withdraw' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>' \
  --header 'Content-Type: application/json' \
  --data '{
  "amount": "220000000000000",
  "assetId": 2,
  "destination": "0x403244EcfafF17c31e39fc67848d61d9b6637Ee2",
  "subaccountId": 8
}'
POST
/users/transfer

POST /users/transfer

ApiKeyApiSignatureApiTimestamp
Request Body
Required
application/json

fromSubaccountId

integerRequireduint64

The subaccount to transfer from.

toSubaccountId

integerRequireduint64

The subaccount to transfer to.

assetId

integerRequireduint64

The asset to transfer. The network is determined by the asset ID.

amount

integerRequireduint128

The amount to transfer. 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.

timestamp

integeruint64

verificationKey

string

Base-64 encoded `cube_ov_utils::ov_schema::PublicKey`

signature

string

Base-64 encoded signature of this withdrawal request

Request Example

application/json

cURL

curl --request POST \
  --url '/users/transfer' \
  --header 'X-API-Key: <value>' \
  --header 'ApiSignature: <value>' \
  --header 'ApiTimestamp: <value>' \
  --header 'Content-Type: application/json' \
  --data '{
  "fromSubaccountId": 1,
  "toSubaccountId": 1,
  "assetId": 1,
  "amount": 1
}'