REST API

The base URL for endpoints described in this page of live trading API is https://api.cube.exchange/os/v0.

Definitions for requests and responses can be found in the Trade OpenAPI Document.

Further specifics for field enums, reject codes, etc. can be found in the Trade API Websocket Documentation.

API Reference

Cube Osmium 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, authentication required

Endpoints in this section require Authentication headers. Note that only API keys with access-level WRITE are able to access any of these endpoints.

GET
/orders

GET /orders

Parameters

subaccountId

queryRequiredinteger

Request Example

cURL

curl --request GET \
  --url '/orders?subaccountId=%3CsubaccountId%3E'
DELETE
/orders

DELETE /orders

Request Body
Required

Cancel all resting orders, optionally limiting to a particular market and / or order book side.

application/json

subaccountId

integerRequireduint64

The subaccount to cancel orders for.

requestId

integerRequireduint64

A request ID that is echoed back on the MassCancelAck and individual CancelOrderAck's.

marketId

integeruint64Nullable

If specified, only orders on the corresponding market will be canceled.

side

integerint32Nullable

If specified, only orders with this side will be canceled.

Request Example

application/json

cURL

curl --request DELETE \
  --url '/orders' \
  --header 'Content-Type: application/json'
POST
/order

POST /order

Request Body
Required

Place a new order. Execution details: - For market orders, exactly one of `quantity` or `quote_quantity` must be specified. - For MARKET_WITH_PROTECTION, if `price` is specified, it will override the default protection price. - Matching will stop upon reaching the protection price, or `quantity` (or `quote_quantity`) filled. - When specifying `quote_quantity`, the order is considered 'fully filled' when there is insufficient remaining quote quantity to fill 1 lot at the next trade price. In that case, there will _not_ be a `CancelOrderAck` published.

application/json

clientOrderId

integerRequireduint64

A unique order ID assigned by the client for this order. The ID must be unique among open orders by this subaccount.

requestId

integerRequireduint64

A request ID that is echoed back on the NewOrderAck or NewOrderReject

marketId

integerRequireduint64

price

integeruint64Nullable

quantity

integeruint64Nullable

Required for LIMIT orders.

side

integerRequiredint32

timeInForce

integerRequiredint32

orderType

integerRequiredint32

subaccountId

integerRequireduint64

The subaccount to place this order on. This subaccount must be writable by the API key specified in the Credentials message.

selfTradePrevention

integerint32Nullable

postOnly

integerRequiredint32

cancelOnDisconnect

booleanRequired

If true, this order will be automatically cancelled after the closure of the network connection between Cube's servers and the client that placed the order. If the client initiates the disconnect or network instability drops the connection, the order will be cancelled when Cube's servers recognize the disconnection. In the event of a server-side disconnect that causes a halt in trading, such as scheduled downtime, the order will be cancelled before trading resumes.

quoteQuantity

integeruint64Nullable

The quantity of the quote asset that the user wants to spend (for a BID) or receive (for an ASK). For limit orders, this is immediately converted to a base quantity using the provided price. For market orders, this is the maximum quantity that will be executed. Note that lot size rules will be respected, and the actual quantity executed will be expressed in base quantity units.

Request Example

application/json

cURL

curl --request POST \
  --url '/order' \
  --header 'Content-Type: application/json' \
  --data '{
  "cancelOnDisconnect": false,
  "clientOrderId": 1721188848244274000,
  "marketId": 100004,
  "orderType": 0,
  "postOnly": 0,
  "price": 656000,
  "quantity": 3300,
  "quoteQuantity": null,
  "requestId": 1721188848288393000,
  "selfTradePrevention": 1,
  "side": 0,
  "subaccountId": 8,
  "timeInForce": 1
}'
DELETE
/order

DELETE /order

Request Body
Required

Cancel a resting order. Note that this can be done before the order is acknowledged (an aggressive cancel) since the identifying field is the `client_order_id`.

application/json

marketId

integerRequireduint64

clientOrderId

integerRequireduint64

The order ID specified by the client on the NewOrder request.

requestId

integerRequireduint64

A request ID that is echoed back on the CancelOrderAck or CancelOrderReject

subaccountId

integerRequireduint64

The subaccount that the NewOrder was placed on.

Request Example

application/json

cURL

curl --request DELETE \
  --url '/order' \
  --header 'Content-Type: application/json'
PATCH
/order

PATCH /order

Request Body
Required

Modify a resting order. - If the `newPrice` and the current resting order's price is the same, and `newQuantity` is not greater, then the modify is considered a modify down, and the FIFO queue priority is maintained. Otherwise, the modify-order request is treated as an atomic cancel-replace and the replacement order is placed at the end of the FIFO queue for the new price level. - If post-only is specified and the replacement order would trade, then the request is rejected and the current resting order remains resting. Currently, in-flight-mitigation (IFM) is always enabled. That is, the cumulative fill qty is subtracted from `newQuantity` to calculate the new resting quantity. For example: ```text | Resting | Filled ---------+---------+-------- New 5 | 5 | 0 Fill 2 | 3 | 2 Modify 4 | 2 | 2 ``` The post-modify quantity will be `newQuantity - filled = 4 - 2 = 2`. Regardless of IFM, the invariant for order quantity is that `quantity = remaining_quantity + cumulative_quantity`.

application/json

marketId

integerRequireduint64

clientOrderId

integerRequireduint64

The order ID specified by the client on the NewOrder request.

requestId

integerRequireduint64

A request ID that is echoed back on the ModifyOrderAck or ModifyOrderReject

newPrice

integerRequireduint64

newQuantity

integerRequireduint64

subaccountId

integerRequireduint64

The subaccount that the NewOrder was placed on.

selfTradePrevention

integerint32Nullable

postOnly

integerRequiredint32

Request Example

application/json

cURL

curl --request PATCH \
  --url '/order' \
  --header 'Content-Type: application/json' \
  --data '{
  "clientOrderId": 1721212575078893000,
  "marketId": 100004,
  "newPrice": 656000,
  "newQuantity": 3300,
  "postOnly": 0,
  "requestId": 1721212575263679000,
  "selfTradePrevention": 1,
  "subaccountId": 8
}'
GET
/positions

GET /positions

Parameters

subaccountId

queryRequiredinteger

Request Example

cURL

curl --request GET \
  --url '/positions?subaccountId=%3CsubaccountId%3E'