Submit a ticket My Tickets
Welcome
Login  Sign up

Authentication

To access the WebSocket server for private real-team data streaming, you must authenticate using the API key. Please refer to How to use the API key? The section on HTTP API.


After you successfully open a connection via WebSocket handshake, you will start to receive a stream of live events for every channel you are subscribed to


GET request parameters:


Field

Description

Multiple allowed

stream

List of streams to be subscribed on

Yes

 

Streams Subscriptions


Using parameters

Streams can be specified to subscribe to bypassing the stream GET parameter in the connection URL. In addition, the parameter can be specified multiple times for subscribing to multiple streams.

Example of using parameters:

wss://exchange.centralex.com/api/v2/ranger/public/?stream=global.tickers&stream=btcusdt.trades

This will subscribe you to tickers and trade events from btcusdt market once the connection is established.

 

Subscribe and unsubscribe events


The subscription connections can be managed by sending the following events after the connection is established.


Subscribe event will subscribe you to the list of streams provided:

{"event":"subscribe","streams":["btcusdt.trades","btcusdt.ob-inc"]}

The server confirms the subscription with the following message and provides the new list of your current subscriptions:

{"event":"subscribe","streams":["btcusdt.trades","btcusdt.ob-inc"]}

Unsubscribe event will unsubscribe you to the list of streams provided:

{"event":"unsubscribe","streams":["btcusdt.trades","btcusdt.ob-inc"]}

The server confirms the unsubscription with the following message and provides the new list of your current subscriptions:

{"success":{"message":"unsubscribed","streams":["global.tickers","btcusdt.kline-15m"]}}

 

Public streams


Please find all existing channels you can subscribe to in the table below:


Name

Streams

Order book Snapshot

Order Book

Order book Increment

Order Book

Trades

Trades

Kline

Kline

Tickers

Tickers

 

Order Book

This stream sends a snapshot of the orderbook at the subscription time, then it sends increments. Volumes information in increments replaces the previous values. For example, the price point should be removed from the order book. if the volume is zero

Register to stream <market>.ob-inc to receive snapshot and increments messages.

 

Endpoint:

wss://exchange.centralex.com/api/v2/ranger/public

Example of subscribing to steams:

{"event":"subscribe","streams":["btcusdt.ob-inc"]}

Response:

Field

Description

asks

List of orders in the format of [price, amount]

bids

List of orders in the format of [price, amount]

 

Example of order-book snapshot response:

{

    "btcusdt.ob-snap":{

        "asks":[

            ["15.0","21.7068"],

            ["20.0","100.2068"],

            ["20.5","30.2068"],

            ["30.0","21.2068"]

        ],

        "bids":[

            ["10.95","21.7068"],

            ["10.90","65.2068"],

            ["10.85","55.2068"],

            ["10.70","30.2068"]

        ]

    }

}

 

Example of order-book increment response:

{

     "btcusdt.ob-inc":{

         "asks":[

             ["15.0","22.1257"]

         ]

     }

 }

 

Trades

Here is the structure of <market>. trades event expose as an array with trades:


Endpoint:

wss://exchange.centralex.com/api/v2/ranger/public

Example of subscribing to steams:

{"event":"subscribe","streams":["btcusdt.trades"]}

Response:

Field

Description

tid

Unique trade tid.

taker_type

Taker type of trade, either buy or sell.

price

Price for the trade.

amount

The amount of trade.

date

The time that trade created in Unix timestamp seconds.

Example of trade response:

{

  "btcusdt.trades": {

    "trades": [{

      "tid": 12345,

      "taker_type": "buy",

      "price": "18004",

      "amount": "0.000027",

      "date": 1605770474

    }]

  }

}

 

Kline point

Here is the structure of kline-<period> event.
(available periods are "1m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d", "3d", "1w")


Endpoint:

wss://exchange.centralex.com/api/v2/ranger/public

Example of subscribing to steams

{"event":"subscribe","streams":["btcusdt.kline-5m"]}

Response:
Kline point as an array of numbers:


Field

Description

Timestamp

Time of the kline in Unix timestamp seconds.

Open price

Open price on the period

Max price

Max price on the period

Min price

Min price on the period

Last price

Last price on the period

volume

Total volume on the period

Example of Kline response:

{

  "btcusdt.kline-5m": [1605771000, 17753, 17753, 17735, 17735, 0.000041]

}

 

Tickers

Here is the structure of global.tickers event expose as an array with all markets pairs:


Endpoint:

wss://exchange.centralex.com/api/v2/ranger/public

Example of subscribing to steams:

{"event":"subscribe","streams":["global.tickers"]}

Response:

Field

Description

at

Date of current ticker in Unix timestamp seconds.

name

Market pair name.

base_unit

Base currency.

quote_unit

Quote currency.

low

Lowest price in 24 hours.

high

The highest price in 24 hours.

last

Last trade price.

open

Last trade from the last timestamp.

close

Last trade price.

volume

Volume in 24 hours.

sell

Best price per unit.

buy

Best price per unit.

avg_price

The average price for the last 24 hours.

price_change_percent

Average price change in percent.

Example of ticker response:

{

  "global.tickers": {

    "btcusdt": {

      "amount": "0.018163",

      "at": "1605771638",

      "avg_price": "17822.8259648737",

      "high": "18043.0",

      "last": "17677.0",

      "low": "17570.0",

      "open": "17875.0",

      "price_change_percent": "-1.11%",

      "volume": "323.715988"

    }

  }

}

 

Private streams

Please find all existing streams you can subscribe to in the table below:

Name

Streams

User’s open orders

Open Orders

User’s orders trades

Trades

 

Open Orders

To get all user’s open orders


Endpoint:

wss://exchange.centralex.com/api/v2/ranger/private

Example of subscribing to steams:

{"event":"subscribe","streams":["order"]}

Response:

Field

Description

id

Unique order id.

market

The market in which the order is placed, e.g. btcusdt

order_type

Order type, either limit or market.

price

Order price.

avg_price

Order average price.

state

One of wait, done, reject, or cancel.

origin_volume

The number of assets the user wants to sell/buy.

remaining_volume

The remaining amount of assets that the user wants to sell/buy.

executed_volume

The executed amount for the current order.

created_at

Time of the order created.

updated_at

Time of the order updated.

trades_count

Trades with this order.

kind

Type of order either bid or ask.

at

Order created time.

Example of orders  response:

{
  "order": {
    "at": 1605843788,
    "avg_price": "17999",
    "created_at": 1605843012,
    "executed_volume": "0.000248",
    "id": 4885,
    "kind": "ask",
    "market": "btcusdt",
    "order_type": "limit",
    "origin_volume": "0.001",
    "price": "17999",
    "remaining_volume": "0.000752",
    "side": "sell",
    "state": "wait",
    "trades_count": 6,
    "updated_at": 1605843788,
    "uuid": "b2cd6cb0-2ae0-11eb-bbe9-c6756a9deae2"
  }
}

 

Trades

To get the user’s trades history


Endpoint:

wss://exchange.centralex.com/api/v2/ranger/private

Example of subscribing to steams:

{"event":"subscribe","streams":["trade"]}

Response:

Field

Description

id

Unique trade identifier.

price

Price for each unit.

amount

The amount of trade.

total

The volume traded (amount * price).

market

The market in which the trade is placed.

side

Type of order of the trade that is related to the current that the user sells or buys.

taker_type

Order side of the taker for the trade, either buy or sell.

created_at

The time of the trade was created.

order_id

User order identifier in trade.

Example of trades response:

{
  "trade": {
    "amount": "0.000014",
    "created_at": 1605843788,
    "id": 928,
    "market": "btcusdt",
    "order_id": 4885,
    "order_uuid": "b2cd6cb0-2ae0-11eb-bbe9-c6756a9deae2",
    "price": "17999",
    "side": "sell",
    "taker_type": "buy",
    "total": "0.251986"
  }
}


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.