API crypto exchanges

Appeal to the API occurs at: http://api.btcindex.io/crex/?method={method}, where {method} — method API.

Methods:

method=tickers (default)

Options:

  • type - type (see list in method ticker_types, поле name)
  • count - number of entries (default 1000, max 1000)
  • tickers - list of tickers, separated by commas, max 30
  • tm - timestamp in seconds, from which to start data output, by default - the count of the last records
  • api_key - access key

The tickers parameter is formed as follows: exchange:symbol

Exchange: exchange name (see list in the method exchanges)

Symbol: name of a pair of tokens (see the products method for a list of tokens), for example ethbtc, first a base token (which we sell / buy), then quote-token (in which we specify the price).

Example: binance:ethbtc - course eth to btc on the binance exchange

As the name of the stock exchange, you can specify “all” - means “aggregated rate from all exchanges ”.

If you specify the tokens in a dash, the cross-rate through btc will be calculated, for example binance:eth-usdt means “cross eth rate to usdt via btc on binance”. You can also specify a cross-token by adding it between base and quote, for example: binance: ltc-eth-usdt means “cross course ltc to usdt via eth on binance”.

Example:

http://api.btcindex.io/crex/?type=1h&count=10&tickers=binance:ethbtc,bitfinex:ethbtc&api_key=


{
    "type": "1h", // requested ticker type
    "tm": 1534298400, // requested tm
    "dt": "2018-08-15 02:00:00", // requested tm in UTC
    "count": 10, // count rows
    "tickers": {
        1534298400: { // start time of the period
            "dt": "2018-08-15 02:00:00", // start time of period in UTC
            "binance:ethbtc": { // first ticker
                 "average": 0.04590245, // weighted average price of trades
                 "buy_volume": 6179.74199828, // volume of purchases
                 "sell_volume": 6030.61199786, // volume of sales
                 "open": 0.045414, // price at the beginning of the period (first transaction)
                 "high": 0.046369, // maximum price for the period
                 "low": 0.045403, // minimum price for the period
                 "close": 0.045713 // end of period price (last transaction)
             },
             "bitfinex:ethbtc": { // second ticker
             }
        }
    }
}

method=ticker_types

List of types of tickers. For example: 1s - one second, 15m - 15 minutes, etc. Suffix “a” (1da) means “moving average” - those. “last 24 hours”, instead of 1d (for the current day by UTC). 1w - weekly tickers begin on Monday. 1M - monthly tickers begin on the first day. 1Ma - moving average for 30 days.

Example:

http://api.btcindex.io/crex/?method=ticker_types&api_key=


{
    "types": {
        "1s": {
            "id": 1,
            "name": "1s", // name
            "update_period": 1 // recurrence frequency, in seconds
        },
        "15s": {
            "id": 2,
            "name": "15s",
            "update_period": 3
        },
}

method=exchanges

List of exchanges.

Example:

http://api.btcindex.io/crex/?method=exchanges&api_key=


method=products

List of tokens.

Example:

http://api.btcindex.io/crex/?method=products&api_key=

API through Websocket

Appeal to the API occurs at: wss://btcindex.io/ws

To receive real-time tickers, we send json:


{
    "method": "subscribe", // subscription for updates
    "type": "1s", // type, see ticker_types above)
    "ticker": "binance:ethbtc" // exchange+pair
}

For a description of the ticker format, see above.

To subscribe to several tickers, send several subscriptions.

In response we get:


{
    "method":"subscribed", // signed
    "type":"1s",
    "ticker":"binance:ethbtc"
}

Further at each recalculation of the ticker we receive the message:


{
    "method":"data", // method name
    "type":"1s", // type ticker
    "ticker":"binance:ethbtc", // name ticker
    "timestamp":1534329887, // start time of the period
    "datetime":"2018-08-15 10:44:47", // time of the beginning of the period in UTC
    // see the description of fields above
    "average":0.04471875,
    "buy_volume":0.186,
    "sell_volume":0.132,
    "open":0.044717,
    "high":0.04472,
    "low":0.044717,
    "close":0.044717
}

For each timestamp, the server sends several messages (every time the data is recalculated).


{"error":"Invalid path alias: @regionStorageUrl","code":0}