NAV Navbar

Introduction

Welcome to CyberX Prime developer documentation.

Before you get started, please make sure you have already created API for portfolios on the CyberX Prime web console.

Endpoint URL

https://brokerage.cyberx.com/api/v1

Standard Response

API response will contains 3 basic fields:

Field Description
code Return 0 if success, or else return the specific error code (see Errors)
message If there's errors, this parameter will contains the details
data This field will return the data you requested
{
    "code": 422,
    "message": "Invalid params, currency BTCC does not exist",
    "data": {},
}

Errors

Unless otherwise stated, errors for bad requests will respond with HTTP 4xx or status codes. The body will also contain a message field indicating the cause. Your language's http library should be configured to provide message bodies for non-2xx requests so that you can read the message field from the body.

Error Code Reason
400 Bad Request - Invalid request format, usually from a bad query string or form parameter.
401 Unauthorized - Invalid API Key or invalid signature.
403 Access Denied - You do not have access to the requested resource.
404 Not Found.
405 Method not allowed - The method is not allowed on this API route.
422 Bad Parameters - Query string, JSON body or form parameter didn't validate properly.
429 Too Many Requests - Request limit is exceeded.
500 Internal Server Error - We had a problem with our server.

Definitions

Order Status

Status Description
SUBMITTED The order has been accepted by the exchange.
PARTIALLY_EXECUTED A part of the order has been filled.
EXECUTED The order has been completed.
CANCELED The order has been canceled by the user.
REJECTED The order was not accepted by the engine and not processed.

Authentication

Overview

All REST requests must contains the following headers:

All request bodies should have content type application/json and be valid to JSON.

Selecting a Timestamp

The nonce parameter contains the number of seconds since Unix Epoch in UTC. Decimal values are allowed.

Your timestamp must be within 60 seconds of the api service time or your request will be considered expired and rejected.

Signing a Message

We use HMAC-SHA256 to generate signature for requests.

Request body:

{
    "exchangeType": "HUOBI",
    "businessType": "SPOT",
    "orderType": "LIMIT",
    "side": "SELL",
    "timeInForce": "GTC",
    "algoType": "DMA",
    "symbol": "XRP/USDT",
    "clientOrderId": "c8a46b5e-43e7-4673-801f-97ae7bf80c72",
    "orderQty": "120",
    "limitPrice": "0.6"
}

To be signed string:

algoType=DMA&businessType=SPOT&clientOrderId=c8a46b5e-43e7-4673-801f-97ae7bf80c72&exchangeType=HUOBI&limitPrice=0.6&orderQty=120&orderType=LIMIT&side=SELL&symbol=XRP/USDT&timeInForce=GTC|1616490537

Create signature:

$ echo -n "algoType=DMA&businessType=SPOT&clientOrderId=c8a46b5e-43e7-4673-801f-97ae7bf80c72&exchangeType=HUOBI&limitPrice=0.6&orderQty=120&orderType=LIMIT&side=SELL&symbol=XRP/USDT&timeInForce=GTC|1616490537" | openssl dgst -sha256 -hmac "1c6591ce-6b4d-4fb3-844e-96492898469e"

Signed result:

c02fa3a14ed681159d111dfddc78c6f4ce2b060b0c5e3186df2d0da66eefbfd1

Request command:

curl --location --request POST 'http://127.0.0.1:8083/oms/api/v1/trade/order' \
--header 'X-MBX-APIKEY: b8ed3e6b-8780-4db1-a6ad-16f1da16d9e4' \
--header 'nonce: 1616493070' \
--header 'signature: 80e9d95d932c049e51950d1231be56101ae53d90632fe306fd5e92f7083fe32b' \
--header 'Content-Type: application/json' \
--data-raw '{
    "exchangeType": "HUOBI",
    "businessType": "SPOT",
    "orderType": "LIMIT",
    "side": "SELL",
    "timeInForce": "GTC",
    "algoType": "DMA",
    "symbol": "XRP/USDT",
    "clientOrderId": "c8a46b5e-43e7-4673-801f-97ae7bf80c72",
    "orderQty": "120",
    "limitPrice": "0.6"
}'

Rest API

Assets

List Assets

Get a list of spot assets from the portfolio of the API key.

HTTP REQUEST

GET /account/asset

PARAMETERS

Name Type Mandatory Description Value Range
exchangeType ENUM YES Exchange name HUOBI, BINANCE, OKEX
businessType ENUM YES Business type contains spot, margin and futures SPOT, MARGIN, COMBINED, FUT, PERP
marginMode ENUM NO Margin mode CROSSED, ISOLATED
currency String NO Crypto currency name BTC, USDT

RESPONSE

Name Type Description Value Range
exchangeType ENUM Exchange name HUOBI, BINANCE, OKEX
businessType ENUM Business type contains spot, margin and futures SPOT, MARGIN, COMBINED, FUT, PERP
currency String Crypto currency name "BTC", "ETH"...
balance String Futures account balance
available String Available ammount in account
locked String Locked ammount in account
marginMode ENUM Margin account CROSSED, ISOLATED
symbol String Response when request isolated margin and futures account "BTC/USDT","ETH/USDT"...
loaned String Loaned amount in margin account
interest String Interest amount in margion account

List Futures Positions

Response:

{
  "data": [
    {
      "exchangeType": "BINANCE",
      "businessType": "FUT",
      "symbol": "BTC/USD",
      "contractType": "THISWEEK",
      "marginCurrency": "BTC",
      "positionSide": "LONG",
      "available": "10000.001235",
      "locked": "100.2323",
      "openAvgPrice": "50000.2323",
      "leverage": "10",
      "liquidatePrice": "30000.4543",
      "realizedProfit": "122.432"
    },
    {
      "exchangeType": "OKEX",
      "businessType": "PERP",
      "symbol": "BTC/USDT",
      "contractType": "PERPETUAL",
      "marginCurrency": "USDT",
      "positionSide": "SHORT",
      "available": "10000.001235",
      "locked": "100.2323",
      "openAvgPrice": "50000.2323",
      "leverage": "10",
      "liquidatePrice": "30000.4543",
      "realizedProfit": "123.432"
    }
  ]
}

HTTP REQUEST

GET /account/position

PARAMETERS

Name Type Mandatory Description Value Range
exchangeType ENUM YES Exchange name HUOBI, BINANCE, OKEX
businessType ENUM YES Business type contains spot, margin and futures COMBINED,FUT,PERP
symbol String NO Trading pair used to request isolated margin and futures account "BTC/USDT","ETH/USDT"...
contractType ENUM NO Contract type PERPETUAL, THISWEEK, NEXTWEEK, QUARTER, BIQUARTERLY

RESPONSE

Name Type Description Value Range
exchangeType ENUM Exchange name HUOBI, BINANCE, OKEX
businessType ENUM Business type contains spot, margin and futures COMBINED,FUT,PERP
symbol String Response when request isolated margin and futures account "BTC/USDT","ETH/USDT"...
contractType ENUM Contract type PERPETUAL, THISWEEK, NEXTWEEK, QUARTER, BIQUARTERLY
marginCurrency BTC Currency used for position margin
positionSide ENUM Position side LONG, SHORT
available String Available ammount in account
locked String Locked ammount in account
openAvgPrice String Position opened average price
leverage String Position leverage
liquidatePrice String Position liquidate price
realizedProfit String Position realized profit

Trades

Place a New Order

HTTP REQUEST

POST /trading/order

PARAMETERS

Name Type Mandatory Description Value Range
exchangeType ENUM YES Exchange name OKEX, HUOBI, BINANCE
businessType ENUM YES Business type contains spot, margin and futures SPOT, MARGIN, COMBINED, FUT, PERP
orderType ENUM NO Order type (Default:LIMIT) LIMIT
side ENUM YES Trading side contains buy and sell BUY, SELL
timeInForce ENUM NO Time in Force (Default : GTC) GTC(Good Till Cancel), GTX(Good Till Crossing), IOC(Immediate or Cancel), FOK(Fil or Kill)
algoType ENUM NO Trading algorithm (Default:DMA) DMA
symbol String YES Trading pair "BTC/USDT", "ETH/USDT"...
clientOrderId String NO Order ID defined by customer
orderQty String YES Order amount
limitPrice String NO Order limit price
contractType ENUM NO Contract type PERPETUAL, THISWEEK, NEXTWEEK, QUARTER, BIQUARTERLY
positionEffect ENUM NO Futures position side OPEN, CLOSE

Spot:

{
  "exchangeType": "BINANCE",
  "businessType": "SPOT",
  "orderType": "LIMIT",
  "side": "BUY",
  "timeInForce": "GTC", // OPTION
  "algoType": "DMA",  // OPTION
  "symbol": "BTC/USDT", 
  "clientOrderId": "c8a46b5e-43e7-4673-801f-97ae7bf80c79",
  "orderQty": "10.5678",
  "limitPrice": "3000.989765"
}

Margin:

{
  "exchangeType": "BINANCE",
  "businessType": "MARGIN",
  "orderType": "LIMIT",
  "side": "BUY",
  "timeInForce": "GTC", // OPTION
  "algoType": "DMA",  // OPTION
  "symbol": "BTC/USDT", 
  "clientOrderId": "c8a46b5e-43e7-4673-801f-97ae7bf80c79",
  "orderQty": "10.5678",
  "limitPrice": "3000.989765"
}

Futures:

{
  "exchangeType": "BINANCE",
  "businessType": "FUT",
  "orderType": "LIMIT",
  "side": "BUY",
  "timeInForce": "GTC", // OPTION
  "algoType": "DMA",  // OPTION
  "symbol": "BTC/USDT", 
  "clientOrderId": "c8a46b5e-43e7-4673-801f-97ae7bf80c79",
  "orderQty": "10.5678",
  "limitPrice": "3000.989765",
  "contractType": "THISWEEK",
  "positionEffect": "OPEN"
}

Perpetual:

{
  "exchangeType": "BINANCE",
  "businessType": "PERP",
  "orderType": "LIMIT",
  "side": "BUY",
  "timeInForce": "GTC", // OPTION
  "algoType": "DMA",  // OPTION
  "symbol": "BTC/USDT", 
  "clientOrderId": "c8a46b5e-43e7-4673-801f-97ae7bf80c79",
  "orderQty": "10.5678",
  "limitPrice": "3000.989765",
  "contractType": "PERPETUAL",
  "positionEffect": "OPEN"
}

RESPONSE

Name Type Description Value Range
orderId String orderId when the order is successfully created

Response:

# Success:

{
  "code": 0,
  "data":
  {
    "orderId": "b5abfc4d-43e7-4673-801f-97ae7bf80c79"
  }
}

# Reject:
{
  "code": 330011,
  "errorMsg": "Param exchange must be send",
  "data": {}
}

Cancel an Order

HTTP REQUEST

DELETE /trading/order

PARAMETERS

Name Type Mandatory Description
orderId String NO Order ID
clientOrderId String NO Order ID defined by customer

Response:

# Success:

{
  "code": 0,
  "data":
  {
    "orderId": "b5abfc4d-43e7-4673-801f-97ae7bf80c79"
  }
}

# Reject:
{
  "code": 330011,
  "errorMsg": "Param orderId must be send",
  "data": {}
}

Cancel All

HTTP REQUEST

DELETE /trading/cancelAll

PARAMETERS

Empty

Response:

# Success:

{
  "code": 0,
  "data": {}
}

Get an Order

Response:

{
    "code": 0,
    "errorMsg": "",
    "data": {
        "orderId": "305d41d3-5245-43cb-a5dc-4640180f49de",
        "clientOrderId": "",
        "exchangeType": "OKEX",
        "businessType": "MARGIN",
        "orderType": "LIMIT",
        "side": "SELL",
        "timeInForce": "GTC",
        "algoType": "DMA",
        "symbol": "XRP/USDT",
        "orderQty": "10",
        "limitPrice": "1.821",
        "executedQty": "10",
        "executedAvgPrice": "1.821",
        "status": "EXECUTED",
        "errorCode": "",
        "errorMsg": "",
        "updateTime": 1618810373634
    }
}

HTTP REQUEST

GET /trading/order

PARAMETERS

Name Type Mandatory Description Value Range
orderId String NO Order ID
clientOrderId String NO Order ID defined by customer

RESPONSE

Name Type Description Value Range
orderId String Order ID
clientOrderId String Order ID defined by customer
exchangeType ENUM Exchange name OKEX, BINANCE, HUOBI
businessType ENUM Business type contains spot, margin and futures SPOT, MARGIN, COMBINED, FUT, PERP
orderType ENUM Order type LIMIT
side ENUM Trading side contains buy and sell BUY, SELL
timeInForce ENUM Time in force (Default : GTC) GTC(Good Till Cancel), GTX(Good Till Crossing), IOC(Immediate or Cancel), FOK(Fil or Kill)
algoType ENUM Trading algorithm (Default:DMA) DMA
symbol String Trading pair "BTC/USDT","ETH/USDT"
orderQty String Order amount
limitPrice String Order limit price
contractType ENUM Contract type PERPETUAL, THISWEEK, NEXTWEEK, QUARTER, BIQUARTERLY
positionEffect ENUM Trading side contains buy and sell OPEN, CLOSE
executedQty String Trading volume
executedAvgPrice String Executed average price
leverage String Leverage
status ENUM Order status OPEN, SUBMITTED, PARTIALLY_EXECUTED, REJECTED, CANCELED, EXECUTED
errorCode String Error code
errorMsg String Error message
updateTime Long Update time

List Open Orders

Response:

[
  {
    "code": 0,
    "errorMsg": "",
    "data": {
        "orderId": "305d41d3-5245-43cb-a5dc-4640180f49de",
        "clientOrderId": "",
        "exchangeType": "OKEX",
        "businessType": "MARGIN",
        "orderType": "LIMIT",
        "side": "SELL",
        "timeInForce": "GTC",
        "algoType": "DMA",
        "symbol": "XRP/USDT",
        "orderQty": "10",
        "limitPrice": "1.821",
        "executedQty": "10",
        "executedAvgPrice": "1.821",
        "status": "EXECUTED",
        "errorCode": "",
        "errorMsg": "",
        "updateTime": 1618810373634
    }
  },
  {
    "code": 0,
    "errorMsg": "",
    "data": {
        "orderId": "e8173192-58e3-4b44-b866-6c864b1e4379",
        "clientOrderId": "",
        "exchangeType": "HUOBI",
        "businessType": "MARGIN",
        "orderType": "LIMIT",
        "side": "BUY",
        "timeInForce": "GTC",
        "algoType": "DMA",
        "symbol": "ETH/USDT",
        "orderQty": "10",
        "limitPrice": "2021.12",
        "executedQty": "10",
        "executedAvgPrice": "2021.12",
        "status": "EXECUTED",
        "errorCode": "",
        "errorMsg": "",
        "updateTime": 1618810747341
    }
  }
]

HTTP REQUEST

GET /trading/openOrders

PARAMETERS

Empty

RESPONSE

Name Type Description Value Range
orderId String Order ID
clientOrderId String Order ID defined by customer
exchangeType ENUM Exchange name OKEX, HUOBI, BINANCE
businessType ENUM Business type contains spot, margin and futures SPOT, MARGIN, COMBINED, FUT, PERP
orderType ENUM Order type Limit
side ENUM Trading side contains buy and sell BUY, SELL
timeInForce ENUM Time in force (Default : GTC) GTC(Good Till Cancel), GTX(Good Till Crossing), IOC(Immediate or Cancel), FOK(Fil or Kill)
algoType ENUM Trading algorithm (Default:DMA) DMA
symbol String Trading pair "BTC/USDT","ETH/USDT"
orderQty String Order amount
limitPrice String Order limit price
contractType ENUM Contract type PERPETUAL, THISWEEK, NEXTWEEK, QUARTER, BIQUARTERLY
positionEffect ENUM Trading side contains buy and sell OPEN, CLOSE
executedQty String Trading volume
executedAvgPrice String Executed average price
leverage String Leverage
status ENUM Order status OPEN, SUBMITTED, PARTIALLY_EXECUTED, REJECTED, CANCELED, EXECUTED
errorCode String Error code
errorMsg String Error message
updateTime Long Update time

Fills

List Fills

Response:

{
    "code": 0,
    "errorMsg": "",
    "data": [
        {
            "orderId": "aaddd4c6-4587-41c5-a621-a8fe73cd5890",
            "executionId": "5db82159-7561-45e1-bb61-3a8de12e6aa3",
            "clientOrderId": "",
            "exchangeType": "OKEX",
            "businessType": "MARGIN",
            "side": "SELL",
            "symbol": "XRP/USDT",
            "fillPrice": 1.82100000000000000000,
            "fillQty": 10.00000000000000000000,
            "commissionFee": 0.00455250000000000000,
            "executionTime": 1618568981362
        }
    ]
}

HTTP REQUEST

GET /trading/executions

PARAMETERS

Name Type Mandatory Description Value Range
orderId String YES Order ID

RESPONSE

Name Type Description Value Range
orderId String Order ID
clientOrderId String Order ID defined by customer
executionId String Execution ID
exchangeType ENUM Exchange name OKEX, BINANCE, HUOBI
businessType ENUM Business type contains spot, margin and futures SPOT, MARGIN, COMBINED, FUT, PERP
side ENUM Trading side contains buy and sell BUY, SELL
symbol String Trading pair "BTC/USDT","ETH/USDT"...
contractType ENUM Contract type PERPETUAL, THISWEEK, NEXTWEEK, QUARTER, BIQUARTERLY
positionEffect ENUM Trading side contains buy and sell OPEN, CLOSE
leverage String Leverage
fillPrice String Filled price
fillQty String Trading volume
commissionFee String Commission fee
executionTime LONG Execution time

WebSocket

Connecting

Establish a WebSocket connection to CyberX Prime:

wss://brokerage.cyberx.com/pusher/865Hsfcd99036bbfee17Dsce6Hfs7928J?protocol=7&client=js&version=6.0.0&flash=false

You'll receive message when connection established:

{
  "event":"pusher:connection_established",
  "data":"{\"socket_id\":\"6.320861\",\"activity_timeout\":120}"
}

Authentication for WS

When you successfully established connection to CyberX Prime WebSocket server, you will get response message with socket_id field.

Use socket_id to get auth key through GET /pusher/auth Rest API (See Get Auth Key).

Get Auth Key

HTTP REQUEST

GET /pusher/auth

PARAMETERS

Name Type Mandatory Description
channelId String YES Format: private-{SN}. When you creating API for a portfolio on CyberX Prime web console, you will get a SN code.
socketId String YES

RESPONSE

Name Type Description
pusherKey String the authKey you need to subscribe to specified WebSocket channel.

Subscribe to Channels

Subscribe to specified channel by sending message to a live WebSocket connection:

{"event": "pusher:subscribe", "data":{"channel": "channelName", "auth": "authKey"}}

Subscription success response:

{
  "event":"pusher_internal:subscription_succeeded",
  "data":"{}",
  "channel":"executions"
}

Channels

[WS] Assets

CHANNEL NAME

assets

Spot:

[
    {
      "exchangeType": "BINANCE",
      "businessType": "SPOT",
      "currency": "USDT",
      "available": "500.1234",
      "locked": "10.42"
    },
    {
      "exchangeType": "HUOBI",
      "businessType": "SPOT",
      "currency": "BTC",
      "available": "10.1234",
      "locked": "0.34"
    }
]

Crossed Margin:


[
    {
      "exchangeType": "BINANCE",
      "businessType": "MARGIN",
      "marginMode": "CROSSED",
      "currency": "USDT",
      "available": "1000.00000",
      "locked": "100.0000",
      "loaned": "500.0000",
      "interest": "1.31415926"
    },
    {
      "exchangeType": "HUOBI",
      "businessType": "MARGIN",
      "marginMode": "CROSSED",
      "currency": "BTC",
      "available": "123.54321",
      "locked": "1.8765",
      "loaned": "10",
      "interest": "1.31415926"
    }
]

Isolated Margin:


[
    {
      "exchangeType": "OKEX",
      "businessType": "MARGIN",
      "marginMode": "ISOLATED",
      "symbol": "BTC/USDT",
      "currency": "USDT",
      "available": "10000.8676",
      "locked": "100.76598",
      "loaned": "1000",
      "interest": "10.7465",
    },
    {
      "exchangeType": "OKEX",
      "businessType": "MARGIN",
      "marginMode": "ISOLATED",
      "symbol": "BTC/USDT",
      "currency": "BTC",
      "available": "10.8676",
      "locked": "0.76598",
      "loaned": "3",
      "interest": "0.7465",
    }
]

futures Crossed Margin:


[
    {
      "exchangeType": "BINANCE",
      "businessType": "COMBINED", // BINANCE special futures type
      "currency": "USDT",
      "balance": "10000.001235"
    },
    {
      "exchangeType": "OKEX",
      "businessType": "FUT",
      "currency": "BTC",
      "balance": "10.001235"
    }
]

futures Isolated Margin:


[
    {
      "exchangeType": "OKEX",
      "businessType": "FUT",
      "symbol": "BTC/USDT",
      "currency": "USDT",
      "balance": "10000.001235"
    },
    {
      "exchangeType": "HUOBI",
      "businessType": "PERP",
      "symbol": "BTC/USDT",
      "currency": "USDT",
      "balance": "10000.001235"
    }
]

[WS] Positions

CHANNEL NAME

Positions

Example Response

[
    {
      "exchangeType": "BINANCE",
      "businessType": "FUT",
      "symbol": "BTC/USD",
      "contractType": "THISWEEK",
      "marginCurrency": "BTC",
      "positionSide": "LONG",
      "available": "10000.001235",
      "locked": "100.2323",
      "openAvgPrice": "50000.2323",
      "leverage": "10",
      "liquidatePrice": "30000.4543",
      "realizedProfit": "122.432"
    },
    {
      "exchangeType": "OKEX",
      "businessType": "PERP",
      "symbol": "BTC/USDT",
      "contractType": "PERPETUAL",
      "marginCurrency": "USDT",
      "positionSide": "SHORT",
      "available": "10000.001235",
      "locked": "100.2323",
      "openAvgPrice": "50000.2323",
      "leverage": "10",
      "liquidatePrice": "30000.4543",
      "realizedProfit": "123.432"
    }
]

[WS] Orders

CHANNEL NAME

orders

Spot/Margin:

{
  "orderId": "b5abfc4d-43e7-4673-801f-97ae7bf80c79",
  "clientOrderId": "c8a46b5e-43e7-4673-801f-97ae7bf80c79",
  "exchangeType": "HUOBI",
  "businessType": "SPOT",
  "orderType": "DMA",
  "side": "SELL",
  "timeInForce": "GTC",
  "algoType": "DMA",
  "symbol": "XRP/USDT",
  "orderQty": "30",
  "limitPrice": "0.32415",
  "executedQty": "30",
  "executedAvgPrice": "0.4",
  "status": "EXECUTED",
  "errorCode": "",
  "errorMsg": "",
  "updateTime": 1610094817067
}

Futures:

{
  "orderId": "b5abfc4d-43e7-4673-801f-97ae7bf80c79",
  "clientOrderId": "c8a46b5e-43e7-4673-801f-97ae7bf80c79",
  "exchangeType": "BINANCE",
  "businessType": "PERP",
  "orderType": "DMA",
  "side": "BUY",
  "timeInForce": "GTC",
  "algoType": "DMA",
  "symbol": "ETH/USDT",
  "contractType": "PERPETUAL",
  "positionEffect": "OPEN",
  "leverage": "10",
  "orderQty": "20",
  "limitPrice": "1000",
  "executedQty": "0",
  "executedAvgPrice": "0",
  "status": "SUBMITTED",
  "errorCode": "",
  "errorMsg": "",
  "updateTime": 1610094817067
}

[WS] Trades

CHANNEL NAME

executions

Spot/Margin:

{
  "orderId": "b5abfc4d-43e7-4673-801f-97ae7bf80c79",
  "clientOrderId": "c8a46b5e-43e7-4673-801f-97ae7bf80c79",
  "executionId": "987658990",
  "exchange": "HUOBI",
  "businessType": "SPOT",
  "side": "BUY",
  "symbol": "XRP/USDT",
  "fillPrice": 0.32415,
  "fillQty": 30,
  "commissionFee": "1.023",
  "executionTime": 1610094817064
}

Futures:

{
  "orderId": "b5abfc4d-43e7-4673-801f-97ae7bf80c79",
  "clientOrderId": "c8a46b5e-43e7-4673-801f-97ae7bf80c79",
  "executionId": "987658990",
  "exchange": "BINANCE",
  "businessType": "PERP",
  "side": "BUY",
  "symbol": "ETH/USDT",
  "contractType": "PERPETUAL",
  "positionEffect": "OPEN",
  "leverage": "10",
  "fillPrice": 800,
  "fillQty": 5,
  "commissionFee": "1.023",
  "executionTime": 1610094817064
}