NAV Navbar
shell
  • Introduction
  • General
  • REST Public Endpoints
  • REST Authenticated Endpoints
  • Websocket General
  • Websocket Public Channels
  • Websocket Private Channels
  • Websocket Actions
  • Introduction

    This page describes Onederx Exchange API. If you are looking for instrument specifications, please visit https://info.onederx.com/.

    A sample implementation of the API client for Python3 is available at https://github.com/onederx/onederx-python/. It can be installed on most systems via python3 -m pip install onederx.

    General

    The API overview

    All interactions with the exchange could be divided into the following groups:

    All interactions can be done both via REST API and via websocket connection.

    Authentication

    In order to receive private data or run actions, you need to generate an API key. This can be done after login at https://trade.onederx.com/user/api.

    An API key consists of the key itself (which is key id on our servers) and key's secret, which is never transmitted over the network after key generation and is used only for generating HMACs.

    The signature is always generated as hex-encoded HMAC-SHA512 with key equal to API secret and the data of the form url_path || <payload>, where || stands for string concatenation. The form of a payload is different for REST and websocket requests.

    For REST requests, the key and the signature are transmitted via APIKEY and SIGNATURE request headers (more). For websocket requests they are transmitted as fields of the websocket message (see corresponding section).

    Error Codes

    $ curl -s 'https://api.onederx.com/invalid_api_method'
    {
      "error_code": 404,
      "error_msg": "the requested resource does not exist"
    }
    
    $ curl -s 'https://api.onederx.com/v1/order/new' --header "APIKEY: this_is_invalid_key"
    {
      "error_code": 7,
      "error_msg": "invalid key",
      "data": {
        "key": "this_is_invalid_key"
      }
    }
    

    In case of error you receive a JSON message containing the error code in the error_code field and a human-readable error description in the error_msg field. It may optionally include additional data in the data field in a machine-readable form.

    Timestamps

    All timestamps are encoded as the number of nanoseconds since Unix Epoch (1 January 1970 GMT).

    REST request encoding

    All REST requests always receive their parameters inside the HTTP request body with content type application/json. The GET HTTP method can be used in case there are no parameters, otherwise POST HTTP method should be used.

    Sequence number

    Every event in the exchange (order addition, order cancellation, or a trade) has its own sequence number. This number is transmitted over the websocket. In a snapshot (received via websocket or http) the sequence number of all items will be the same and represents the sequence number of the last event included in the snapshot.

    Level 2 data has its own sequence number, which is not related to the sequence number of the Level 3 data.

    Rate limits

    Currently, Onederx allows 50 requests/sec for an API key or IP address (both limitations apply). The limit applies both to HTTP endpoints and to websocket actions.

    The rate limit may be lower for endpoints with large responses (e.g. l3/l2 orderbook snapshots).

    REST Public Endpoints

    Status

    $ curl -s 'https://api.onederx.com/v1/status'
    {
      "error_code": 0,
      "error_msg": "the operation was completed successfully"
    }
    

    Endpoint URL: https://api.onederx.com/v1/status

    This endpoint checks the connection of the specified backend with the exchange engine and validates the status of the exchange engine.

    Symbol details

    $ curl -s "https://api.onederx.com/v1/symbol_details"
    [
      {
        "symbol_type": "futures",
        "symbol": "BTCUSD_P",
        "quote_curr": "BTC",
        "quote_curr_precision": 8,
        "price_curr": "USD",
        "maker_fee": "-0.0002",
        "taker_fee": "0.0007",
        "price_step": "0.5",
        "contract_type": "inverse",
        "contract_size": "100",
        "underlying_index": "BTCUSD",
        "max_leverage": 20,
        "index_termination_payment": "5"
      }
    ]
    

    Endpoint URL: https://api.onederx.com/v1/symbol_details

    This endpoint returns details for all supported symbols. Most fields of the response have self-descriptive names (see example), but note the following:

    Ticker

    curl -s "https://api.onederx.com/v1/ticker" --data '{"symbol": "BTCUSD_P"}'
    {
      "symbol": "BTCUSD_P",
      "last_trade_id": 1708408,
      "time": 1543927575577695500,
      "last_trade_price": "3949",
      "price_24h_ago": "3990",
      "low_price_24h": "3788.5",
      "high_price_24h": "3993",
      "volume_24h": "78785",
      "mark_price": "3983.87"
    }
    

    Endpoint URL: https://api.onederx.com/v1/ticker

    This endpoint returns basic trade information for a given symbol. All fields of the response have self-descriptive names (see example).

    L2 snapshot

    curl -s "https://api.onederx.com/v1/l2" --data '{"symbol": "BTCUSD_P"}'
    [
      {
        "seq_num": 4762,
        "symbol": "BTCUSD_P",
        "side": "buy",
        "price": "3052.5",
        "volume": "162",
        "count": 1,
        "timestamp": 1543861085701615000
      },
      ...
    ]
    

    Endpoint URL: https://api.onederx.com/v1/l2

    This endpoint returns L2 order book snapshot. It requires a symbol name and returns the array of all quotes. Most fields of the response have self-descriptive names, but note the following:

    L3 snapshot

    curl -s "https://api.onederx.com/v1/l3" --data '{"symbol": "BTCUSD_P"}'
    [
      {
        "seq_num": 4762,
        "action": 1,
        "symbol": "BTCUSD_P",
        "order_id": 2377,
        "cl_ord_id_sha256": "5441688e46c72a05d4dc1f52afe94a5e4cbf41ce37c4d60f10326ed079c92be0",
        "side": "buy",
        "type": "limit",
        "time_in_force": "gtc",
        "price": "3052.5",
        "volume": "162",
        "initial_volume": "162",
        "event_time": 1543838783521817300
      },
      ...
    ]
    

    Endpoint URL: https://api.onederx.com/v1/l3

    This endpoint returns L3 order book snapshot. It requires a symbol name and returns the array of all active orders. Most fields of the response have self-descriptive names, but note the following:

    Trades snapshot

    Endpoint URL: https://api.onederx.com/v1/trades

    curl -s "https://api.onederx.com/v1/trades" --data '{"symbol": "BTCUSD_P"}'
    [
      {
        "symbol": "BTCUSD_P",
        "id": 1700904,
        "maker_id": 3010052,
        "taker_id": 3010054,
        "type": "normal",
        "side": "buy",
        "price": "3937",
        "volume": "2",
        "event_time": 1543923139114689300
      },
      ...
    ]
    

    This endpoint returns the last 100 trades for a specific symbol. It requires the symbol name and returns an array of last trades. Most fields of the response have self-descriptive names, but note the following:

    The type field can be one of the following:

    Candlesticks History

    curl -s "https://api.onederx.com/v1/candles" -d '{
                                                        "symbol":"BTCUSD_P",
                                                        "resolution":"1m",
                                                        "from":1543839025139307008,
                                                        "to":1543925391632289792
                                                      }'
    [
      {
        "symbol": "BTCUSD_P",
        "resolution": "1m",
        "close_deal_id": 1647610,
        "time": 1543839060000000000,
        "open": "3974",
        "close": "3976",
        "low": "3960",
        "high": "3976",
        "volume": "230"
      },
      ...
    ]
    

    Endpoint URL: https://api.onederx.com/v1/candles

    This endpoint returns all candles for a given symbol of specific resolution in a period of time [from, to]. The parameters from and to are encoded as the number of nanoseconds elapsed since Unix Epoch (1 January 1970 GMT).

    The resolution parameter must be one of the following:

    All fields of the response have self-descriptive names.

    REST Authenticated Endpoints

    How to sign a message

    Authentication is done using the API key and a secret.

    The authentication procedure is as follows:

    Note that:

    All authenticated Endpoints use POST requests. For websocket authentication see the corresponding section of this manual.

    Place Order

    $ curl "https://api.onederx.com/v1/order/new" \
             --header "APIKEY: 9147c07be7072c62b68c542bbfeb286f" \
             --header "SIGNATURE: 7f79fb1a514f5357232b50cb51ebec653bc55ce6a361d39ef5ca6ecfc12d88366dae3ae67a9b2c8ea2cf0d2aa10f956608a7633f54a318c49a64f4cd94299938" \
             --data '{
                         "post_only": false,
                         "price": "5000",
                         "side": "sell",
                         "symbol": "BTCUSD_P",
                         "time_in_force": "gtc",
                         "timestamp": 1543940390985261824,
                         "type": "limit",
                         "volume": 3
                     }'
    {
      "order_id": 3043841,
      "error_code": 0
    }
    

    Endpoint URL: https://api.onederx.com/v1/order/new

    This endpoint places a new order.

    It takes the following parameters:

    Place a Stop

    $ curl "https://api.onederx.com/v1/order/new" \
             --header "APIKEY: 9147c07be7072c62b68c542bbfeb286f" \
             --header "SIGNATURE: 11153c2daf946fb54a36c46efc862304127d4b1526f0237af5608a137ecaf5379e4f8336f91d2f3555f2d242eb6e637364f4f2558338df0e0514724c539f201d" \
             --data '{
                         "cl_ord_id": "my stop order #42",
                         "price": "10000",
                         "side": "buy",
                         "stop": true,
                         "symbol": "BTCUSD_P",
                         "timestamp": 1543943418381992960,
                         "type": "market",
                         "volume": 1
                     }'
    {
      "order_id": 3044529,
      "error_code": 0
    }
    

    Endpoint URL: https://api.onederx.com/v1/order/new

    This endpoint creates a new stop order. It takes the same parameters as place order endpoint with the following differences: