NAV Navbar
curl
  • Introduction
  • Permissions
  • Authentication
  • Integration
  • Constants
  • Supported Currencies
  • Crypto Metadata
  • Price Data
  • Historical Data
  • Exchange Data
  • Algorithm Weighting
  • Price Conversion
  • Blockchain Tools
  • Websocket API
  • Websocket API V2
  • Websocket API V3
  • Errors
  • Introduction

    Welcome to the BitcoinAverage API! The world's best and longest running Cryptocurrency price API provider.

    These APIs can be used to gather real-time, OHLC, volume and historical price data for the following Cryptocurrencies:

    Bitcoin (BTC), Bitcoin Cash (BCH), Litecoin (LTC), Ethereum (ETH), Dash (DASH), Ripple (XRP), Monero (XMR) plus many more.

    The full list of supported cryptocurrency markets can be found at this endpoint: Price Symbols

    The full list of cryptocurrencies and tokens with full names is here: Full Names

    Our Cryptocurrency price data is sourced and aggregated from exchanges all over the world, a selection of these can be found below:

    Coinbase Pro, Bitstamp, Bitfinex, Kraken, Binance, Poloniex, Bittrex, Huobi, LocalBitcoins, ItBit, HitBTC, Coinfloor, LakeBTC, Gemini, Exmo, Korbit, QuadrigaCX, Bitsquare, Quoine, Luno, Independant Reserve, Coinmate, Bitbay, Paymium, Rocktrading, CampBX, Loyalbit, Spacebtc, Mexbt, Okcoin, Btcc, Btc38, Bitflyer.

    The full list of integrated cryptocurrency exchanges and their orderbook symbols can be found at this endpoint: Exchange Symbols

    DISCLAIMER

    ANY ACCESS AND USE OF THE API AND OUR DATA IS SOLELY YOUR RESPONSIBILITY. FOR FULL TERMS AND CONDITIONS PLEASE CLICK HERE

    Permissions

    Most endpoints are available to all plans, however some do require higher plans. The current available plans are:

    If an endpoint requires special permissions, the level required will be outlined.

    Authentication

    All requests to our API must be authenticated with your public key.

    First register an account.

    Then choose one of our plans from the plans page.

    Finally get your public key from the main dashboard.

    Signing

    All of our request are get request and they must contain our x-ba-key header:

    Example: 'x-ba-key': 'NzI0MjM4Njc1NGQ3NDU4Mzg1NWU3YYmU4MTdiMaA'

    Integration

    Github Code Snippets

    Integration examples in multiple programming languages can be found on our GitHub repository.

    We are looking to expand the languages we support, if you are interested in helping out please get in touch! support@bitcoinaverage.com

    Python PIP library

    This is as simple as running the following command in console:

    pip install bitcoinaverage

    For more details please visit: https://pypi.org/project/bitcoinaverage/

    You can find out usage examples for all functions provided by our PIP library on our GitHub repository.

    NPM NodeJS library

    This is as simple as running the following command in console:

    npm install bitcoinaverage

    For more details please visit: https://www.npmjs.com/package/bitcoinaverage

    Constants

    Endpoints to return active symbols, exchange rates and server time for use in other endpoints where required.

    Fiat Exchange Rates

    Example Request

    $ curl https://apiv2.bitcoinaverage.com/constants/exchangerates/global
    

    Example Response

    {
        "time": "23-03-2016 16:59:19",
        "rates": {
            "MXN": {
                "name": "Mexican Peso",
                "rate": "17.48512"
            },
            "USD": {
                "name": "United States Dollar",
                "rate": "1"
            },
            "JPY": {
                "name": "Japanese Yen",
                "rate": "112.5204"
            },
            "KRW": {
                "name": "South Korean Won",
                "rate": "1161.976675"
            },
        },
    }
    

    Returns global fiat exchange rates used in the current indices calculations.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/constants/exchangerates/{market}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    market False Market. Options: global,local

    Server Time

    Example Request

    $ curl https://apiv2.bitcoinaverage.com/constants/time
    

    Example Response

    {
      "epoch": 1458754280,
      "iso": "2016-03-23T17:31:20"
    }
    

    Returns our server time that can be used as a check when using API Key authentication

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/constants/time

    PERMISSIONS

    Cryptocurrencies and Tokens by name

    Example Request

    $ curl https://apiv2.bitcoinaverage.com/info/indices/names/
    

    Example Response

    {
        "tokens": {
            "BAT": "Basic Attention Token",
            "BRD": "Bread token",
            "BTM": "BitMark",
            "SUB": "Substratum Network",
            "TNB": "Time New Bank",
            "ZRX": "0x",
            "APPC": "AppCoins",
            "BTM*": "Bytom",
            "CVC": "Civic",
            "PAX": "Paxos Standard Token",
            "PLC": "PlusCoin",
            "MAID": "MaidSafe Coin",
            ...
        },
        "crypto": {
            "ADA": "Cardano",
            "RDD": "ReddCoin",
            "BTCD": "BitcoinDark",
            "BCN": "ByteCoin",
            "GRS": "Groestlcoin",
            "MONA": "MonaCoin",
            "ARK": "ARK",
            "ETC": "Ethereum Classic",
            "NEBL": "Neblio",
            "XVG": "Verge",
            "VET": "VeChain",
            "ZEC": "ZCash",
            "NEO": "NEO",
        }
    }
    

    Returns full names of all supported cryptocurrencies and tokens

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/info/indices/names/

    PERMISSIONS

    Supported Currencies

    Our APIs support 5 sets of symbols. When requesting any price related endpoint you will need to specify which set of symbols your required symbols resides in.

    The Symbols (currency pairs), are a core concept of our platform, understanding how each symbols is derived is crucial for efficient usage of our APIs, please take the time to ensure you are aware of where and why they reside. If further clarification is needed please do Email Us and we will be more than happy to assist, or join us on Slack!

    Below you can find descriptions for each symbol_set.

    Symbol_Set Description Example
    Global This set provides global symbols that are derived from the Local currency markets. Symbols supported in this set will comprise a Cryptocurrency against approximately 170 fiat currencies. BTCUSD,BTCMKD,ETHAUD
    Local This set includes Cryptocurrencies that are actively traded to a fiat currency on an exchange. These are also known as our Currency Markets. BTCUSD,ETHEUR,LTCUSD
    Crypto This set comprises Crypto/Crypto pairs only. XMRBTC,ETHXRP,LTCETH
    Tokens This set includes any Token that is not in itself a coin or crypto, and instead resides on top of another blockchain such as Ethereum. These symbols can either be Token/Crypto or Token/Fiat OMGUSD,REPBTC,EOSBTC
    Light This set includes Tokens and Cryptocurrencies that are more obscure but show potential. The responses from this symbol set are shorter but still provide all essential market data.

    Price Symbols (Ticker)

    Returns a list of symbol sets and supported symbols for ticker endpoints.

    Calculating reverse symbols

    If you wish to get price data for say Bitcoin to Ethereum, symbol BTCETH, but only ETHBTC is supported in our API, you can easily derive the BTCETH price data from our ETHBTC price data.

    1. For all prices: Calculate 1/price. For example if the last value for ETHBTC is 0.0406, then BTCETH = 1 / 0.0406 = 24.63
    2. For volume: Multiply the given volume by the given last price. With the ETHBTC example, if the volume in ETH is 527348 and the last price is 0.0406 then the volume in BTC will be 527348 * 0.0406 = 21410.328

    Example Request

    $ curl https://apiv2.bitcoinaverage.com/info/indices/ticker
    
    

    Example Response

    {
        "local": {
            "symbols": [
                "BTCAUD",
                "BTCBRL",
                "BTCCAD",
            ]
        },
        "global": {
            "symbols": [
                "BTCAED",
                "BTCAFN",
                "BTCALL",
            ]
        },
        "success": true
    }
    

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/info/indices/ticker/{symbol_set}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    symbol_set False Symbol Set. Options: global,local,crypto,tokens,light

    Price Symbols (Historical)

    Example Request

    $ curl https://apiv2.bitcoinaverage.com/info/indices/history
    

    Example Response

    {
        "symbols": [
            "BTCAUD",
            "BTCBRL",
            "BTCCAD",
        ],
        "success": true
    }
    

    Returns a list of symbol sets and supported symbols for historical data endpoints.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/info/indices/history/{symbol_set}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    symbol_set False Symbol Set. Options: global,local,crypto,tokens

    Exchange Symbols (Ticker)

    Example Request

    $ curl https://apiv2.bitcoinaverage.com/info/exchanges/ticker
    
    

    Example Response

    {
        "exchanges": {
            "hitbtc": {
                "symbols": [
                    "BCNBTC",
                    "BTCUSD",
                    "DASHBTC",
                    "DOGEBTC",
                    "DOGEUSD",
                    "EMCBTC",
                    ...
                    ]
            },
            "coinbasepro": {
                "symbols": [
                    "LTCEUR",
                    "BTCUSD",
                    "BTCEUR",
                    "BCHBTC",
                    "LTCBTC",
                    "ETHEUR",
                ]
            }
        }
    }
    

    Returns a list of supported symbols for exchange ticker endpoints.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/info/exchanges/ticker

    PERMISSIONS

    Exchange Symbols (Historical)

    Example Request

    $ curl https://apiv2.bitcoinaverage.com/info/exchanges/history
    

    Example Response

    {
        "symbols": [
            "BTCAUD",
            "BTCBRL",
            "BTCCAD",
        ],
        "success": true
    }
    

    Returns a list of supported symbols for exchange historical data endpoints.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/symbols/indices/history

    PERMISSIONS

    Crypto Metadata

    We provide metadata for Cryptocurrencies including their Market Caps. This is a new endpoint and will be expanding over the coming months.

    Metadata

    Example Request

    $ curl -H https://apiv2.bitcoinaverage.com/metadata
    

    Example Response

    
    {
        "XRP": {
            "volume": 298540280.0888047,
            "change_percent": 8.63,
            "market_cap": 114585354368.5959,
            "change_price": 0.23,
            "low": 2.333,
            "bid": 2.95385,
            "last": 2.95787,
            "ask": 2.95787,
            "high": 3.2
        },
        "ZEC": {
            "volume": 9901767.491939863,
            "change_percent": -6.41,
            "market_cap": 1555241089.5,
            "change_price": -35.73,
            "low": 515.01,
            "bid": 521.51,
            "last": 521.52,
            "ask": 521.8,
            "high": 565.54
        },
    }
    

    This endpoint returns metadata and market information for all suppported symbols.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/metadata

    PERMISSIONS

    Price Data

    We provide a single Global index, Local indices, Cryptocurrency indices and Tokens indices.

    All endpoints in this collection require the symbol_set parameter to be provided in the URL.

    Ticker Data (All)

    Returns data for all symbols from symbols set.

    Example Request

    
    $ curl -H "X-testing: testing" https://apiv2.bitcoinaverage.com/indices/global/ticker/all?crypto=BTC&fiat=USD,EUR
    
    

    Example Response

    
    {
      "BTCUSD": {
        "ask": 659.82,
        "bid": 659.14,
        "last": 659.58,
        "high": 660.59,
        "low": 653.86,
        "open": {
          "day": 653.99,
          "week": 665.5,
          "month": 638.03
        },
        "averages": {
          "day": 656.36,
          "week": 656.34,
          "month": 657.07
        },
        "volume": 98908.81,
        "changes": {
          "percent": {
            "day": 0.85,
            "week": -0.89,
            "month": 3.38
          },
          "price": {
            "day": 5.59,
            "week": -5.92,
            "month": 21.55
          }
        },
        "volume_percent": 29.57,
        "timestamp": 1469802310,
        "display_timestamp": "2016-07-29 14:25:10"
      }
    }
    

    Api call credits

    This endpoint can return well over 100 data points and can spend more than one API call credit. One credit call is used for 100 data points, rounded up.

    If one response contains between 101 and 200 data points you will spend 2 call credits. If it contains between 201 and 300 data points you will spend 3 call credits etc.

    Filtering

    No query parameters

    If no query parameters are sent, ticker data for every supported symbol is returned.

    Example request:

    GET https://apiv2.bitcoinaverage.com/indices/{symbol_set}/ticker/all

    Symbols parameter

    List of symbols to be returned, separated by comma.

    Example request:

    GET https://apiv2.bitcoinaverage.com/indices/{symbol_set}/ticker/all?symbols=BTCUSD,LTCUSD,ETHUSD

    Crypto and Fiat parameters

    Example request:

    GET https://apiv2.bitcoinaverage.com/indices/{symbol_set}/ticker/all?crypto=BTC&fiat=USD,EUR,GBP

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    symbol_set True Symbol Set. Options: global,local,crypto,tokens,light.
    symbols False Comma separated list of symbols to return. Example: BTCUSD,LTCEUR,ETHGBP.
    crypto False One or more base cryptocurrencies separated by comma. Example: BTC,LTC.
    fiat False One or more target fiat currencies or cryptocurrencies separated by comma. Example: USD,EUR,GBP.

    Ticker Data (Per Symbol)

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/indices/global/ticker/BTCUSD
    
    

    Example Response

    {
        "ask": 418.79,
        "bid": 418.35,
        "last": 418.66,
        "high": 418.83,
        "low": 417.1,
        "open": {
            "day": "417.73",
            "week": "408.74",
            "month": "439.27"
        },
        "averages": {
            "daily": 418.98,
            "weekly": 418.39,
            "monthly": 419.76
        },
        "volume": 56542.49,
        "changes": {
            "price": {
                "weekly": 9.92,
                "monthly": -20.62,
                "daily": 0.93
            },
            "percent": {
                "weekly": 2.43,
                "monthly": -4.69,
                "daily": 0.22
            }
        },
        "volume_percent": 66.42,
        "timestamp": 1458754392,
        "display_timestamp": "Wed, 23 Mar 2016 17:33:12 +0000"
    }
    

    Returns ticker data for specified symbol

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/indices/{symbol_set}/ticker/{symbol}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    symbol_set True Symbol Set. Options: global,local,crypto,tokens
    symbol True Full currency pair symbol. Example: BTCUSD

    Short Ticker (local and global symbols sets)

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/indices/global/ticker/short?crypto=BTC&fiat=USD,EUR
    
    

    Example Response

    {
        "BTCUSD": {
            "last": 7008.87,
            "bid": 7001.27,
            "ask": 7010.12,
            "averages": {
                "daily": 6992.88882018
            }
        },
        "BTCEUR": {
            "last": 5990,
            "bid": 5989,
            "ask": 5992.42,
            "averages": {
                "daily": 5997.21898
            }
        }
    }
    

    Returns basic ticker denoting bid, ask, last prices and daily average price for the specified crypto/fiat values

    Filtering

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/indices/{symbol_set}/ticker/short?crypto={crypto}&fiat={fiat,fiat}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    symbol_set True Symbol Set. Options: global,local
    crypto False Filters repsonse by supplied crypto currency. Example: BTC. (Accepts comma separated values)
    fiat False Filters repsonse by supplied fiat currency. Example: USD. (Accepts comma seperated values)

    Short Ticker (crypto and tokens symbols sets)

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/indices/crypto/ticker/short?base=DASH,NEO&target=BTC,ETH
    
    

    Example Response

    {
        "DASHBTC": {
            "last": 0.021395266752125056,
            "averages": {
                "day": 0.05197267
            },
            "timestamp": 1535089680,
            "ask": 0.021434040608448474,
            "bid": 0.021342895647318318
        },
        "DASHETH": {
            "last": 0.5057714133779478,
            "averages": {
                "day": 0.58314002
            },
            "timestamp": 1535089681,
            "ask": 0.5066995885976693,
            "bid": 0.5053734038463437
        },
        "NEOBTC": {
            "last": 0.00269529815470372,
            "averages": {
                "day": 0.00814457
            },
            "timestamp": 1535089685,
            "ask": 0.002696300117623886,
            "bid": 0.002693643744789217
        },
        "NEOETH": {
            "last": 0.06380616754597206,
            "averages": {
                "day": 0.09714228
            },
            "timestamp": 1535089685,
            "ask": 0.06384968777133948,
            "bid": 0.0637315057381096
        }
    }
    

    Returns basic ticker denoting bid, ask, last prices and daily average price for the specified base and target cryptocurrencies

    Filtering

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/indices/{symbol_set}/ticker/short?base={crypto1,crypto2}&target={crypto3,crypto4}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    symbol_set True Symbol Set. Options: crypto,tokens
    base False Filters repsonse by supplied base cryptocurrency. Example: XRP,XMR. (Accepts comma separated values)
    target False Filters response by supplied target cryptocurrency. Example: BTC,ETH. (Accepts comma separated values)

    Ticker Changes

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/indices/global/ticker/BTCUSD/changes
    
    

    Example Response

    {
        "ask": 8225.76,
        "bid": 8222.93,
        "last": 8223.63,
        "high": 8313.77,
        "low": 7955.56,
        "open": {
            "hour": 8238.45,
            "day": 8245.40,
            "week": 8290.93,
            "month": 10053.14,
            "month_3": 10581.66,
            "month_6": 5305.08,
            "year": 6523.43
        },
        "averages": {
            "day": 8161.87,
            "week": 8102.44,
            "month": 8402.22
        },
        "volume": 34667.79597980864,
        "changes": {
            "price": {
                "hour": -14.82,
                "day": -21.77,
                "week": -67.30,
                "month": -1829.51,
                "month_3": -2358.03,
                "month_6": 2918.55,
                "year": 1700.20
            },
            "percent": {
                "hour": -0.18,
                "day": -0.26,
                "week": -0.81,
                "month": -18.20,
                "month_3": -22.28,
                "month_6": 55.01,
                "year": 26.06
            }
        },
        "volume_percent": 73.59156278986163,
        "timestamp": 1571651403,
        "display_timestamp": "2019-10-21 09:50:03",
        "display_symbol": "BTC-USD"
    }
    

    Returns ticker values and price changes for specified symbol_set and symbol.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/indices/{symbol_set}/ticker/{symbol}/changes

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    symbol_set True Symbol Set. Options: global,local,crypto,tokens
    symbol True Full currency pair symbol. Example: BTCUSD

    Custom Ticker

    Example Request

    
    $ curl -H "X-Testing: testing" https://apiv2.bitcoinaverage.com/indices/ticker/custom/include/BTCUSD?exchanges=bitstamp,bitfinex
    
    

    Example Response

    {
        "timestamp": 1496934885,
        "bid": {
            "price": 2774.53
        },
        "ask": {
            "price": 2776.85
        },
        "last": {
            "price": 2776.85
        }
    }
    

    Returns ticker values and price changes for specified symbol_set and symbol.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/indices/ticker/custom/{inex}/{symbol}?exchanges={exchange_list}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    inex True Include or Exclude the provided exchange_list. Options: include or exclude
    exchanges True A comma seperated list of exchanges.

    Historical Data

    Improvement to the History Data API

    Previously our history API automatically returned minute data when your request timestamp was within 24h period, afterwards it automatically moved to hour data from 1 day to 30 days and then provided day data when the timestamp exceeded 30 days in the past.

    This resulted in different api responses when the same timestamp was requested just two days apart.

    We have improved this by adding a resolution parameter that lets you specify what type of dataset you would like to access: minute, hour or day.

    Api call credits

    This endpoint can return well over 100 data points and can spend more than one API call credit. One credit call is used for 100 data points, rounded up.

    If one response contains between 101 and 200 data points you will spend 2 call credits. If it contains between 201 and 300 data points you will spend 3 call credits etc.

    History limits by plan

    The history API endpoints will return different data size depending on your plan.

    Plan Minute Hour Day
    Developer 2 hours 10 days 3 months
    Startup 24 hours 31 days 1 year
    Grow 24 hours 31 days 7 years
    Dominate 24 hours 31 days 7 years

    These limits are enforced for all history endpoints:

    Historical Data

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/indices/global/history/BTCUSD?period=minute
    
    

    Example Response

    [
        {
            "time": "2019-10-21 09:48:00",
            "average": 8223.57
        },
        {
            "time": "2019-10-21 09:47:00",
            "average": 8223.09
        },
        {
            "time": "2019-10-21 09:46:00",
            "average": 8219.92
        },
        {
            "time": "2019-10-21 09:45:00",
            "average": 8216.57
        },
        {
            "time": "2019-10-21 09:44:00",
            "average": 8218.51
        },
        {
            "time": "2019-10-21 09:43:00",
            "average": 8220.91
        },
        {
            "time": "2019-10-21 09:42:00",
            "average": 8218.39
        },
        ...
    

    Return historical ticker data for 'symbol'. Optional 'format' parameter with value csv/json

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/indices/{symbol_set}/history/{symbol}?period={period}

    URL PARAMETERS

    Parameter Required Description
    symbol_set True Symbol Set. Options: global,local,crypto,tokens
    symbol True Full currency pair symbol. Example: BTCUSD
    period False Data set period. Options: minute,hour,day
    format False Response format. Options: json,csv

    Period parameter

    History Data Since Timestamp

    Example Request

    
    $ curl -H "X-Testing: testing" https://apiv2.bitcoinaverage.com/indices/global/history/BTCUSD?since=1405394590&resolution=hour
    
    

    Example Response

    [
        {
            "ts": 1460624400.0,
            "average": 424.06,
            "time": "2016-04-14 09:00:00"
        },
        {
            "ts": 1460620800.0,
            "average": 423.90,
            "time": "2016-04-14 08:00:00"
        },
        {
            "ts": 1460617200.0,
            "average": 424.14,
            "time": "2016-04-14 07:00:00"
        },
    ]
    

    Return historical ticker data since 'timestamp' until present moment.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/indices/{symbol_set}/history/{symbol}?since={timestamp}&resolution={resolution}

    URL PARAMETERS

    Parameter Required Description
    symbol_set True Symbol Set. Options: global,local,crypto,tokens
    symbol True Full currency pair symbol. Example: BTCUSD
    since True Timestamp in unix format. Example: 1405394590
    resolution True Possible values: minute, hour, day.

    Resolution

    Depending on the resolution parameter you will receive that in minute, hour or day resolution.

    Price At Timestamp

    Example Request

    
    $ curl -H "X-Testing: testing" https://apiv2.bitcoinaverage.com/indices/global/history/BTCUSD?at=1402476700&resolution=day
    
    

    Example Response

    {
        "average": 424.79,
        "time": "2016-04-14 00:00:00"
    }
    

    Return price at specified timestamp (unix format), at specific resolution.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/indices/{symbol_set}/history/{symbol}?at={timestamp}&resolution={resolution}

    URL PARAMETERS

    Parameter Required Description
    symbol_set True Symbol Set. Options: global,local,crypto,tokens
    symbol True Full currency pair symbol. Example: BTCUSD
    since True Timestamp in unix format. Example: 1402476700
    resolution True Possible values: minute, hour, day.

    Exchange Data

    The endpoints in this section provide real-time exchange data and other metrics.

    If you require historical exchange data please refer to the Historical Data section.

    Exchange Data (Per Exchange)

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/exchanges/ticker/bitstamp
    
    

    Example Response

    {
        "name": "bitstamp",
        "display_name": "Bitstamp",
        "url": "https://bitstamp.net/",
        "timestamp": 1458755191,
        "data_source": "api",
        "symbols": {
            "BTCUSD": {
                "last": 2419.82,
                "volume": 34209.98,
                "ask": 2419.76,
                "bid": 2412.56,
                "high": 2756.16,
                "low": 2230.00,
                "open": 2451.42,
                "vwap": 2504.92
            },
            ...
        }
    }
    

    Returns all price data for specific exchange.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/exchanges/ticker/{exchange_name}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    exchange_name True Name of the exchange. Example: bitstamp

    Exchange Data (All)

    Example Request

    
    $ curl -H "X-testing: testing" https://apiv2.bitcoinaverage.com/exchanges/ticker/all
    
    

    Example Response

    [
        {
            "name": "bitcurex",
            "display_name": "Bitcurex",
            "url": "https://bitcurex.com/",
            "timestamp": 1458755176,
            "data_source": "api",
            "symbols": {
                "BTCPLN": {
                    "ask": 1610.00,
                    "bid": 1609.00,
                    "last": 1610.00,
                    "volume": 47.22
                },
                "BTCEUR": {
                    "ask": 373.10,
                    "bid": 370.23,
                    "last": 373.10,
                    "volume": 98.86
                },
                ...
            }
        },
        {
            "name": "bitex",
            "display_name": "Bitex.la",
            "url": "https://bitex.la/",
            "timestamp": 1458755194,
            "data_source": "api",
            "symbols": {
                "BTCUSD": {
                    "ask": 417.00,
                    "bid": 415.57,
                    "last": 416.70,
                    "volume": 133.54
                },
                ...
            }
        },
    ]
    

    Returns a list of all exchanges with their integrated symbols and data. Data can be filtered by crypto and/or fiat currency

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/exchanges/ticker/all?crypto={crypto}&fiat={fiat}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    crypto False Filters repsonse by supplied crypto currency. Example: BTC,LTC. Accepts one or more comma separated values.
    fiat False Filters repsonse by supplied fiat currency. Example: USD,EUR,GBP. Accepts one or more comma seperated values.

    Example advanced filtering

    URL: https://apiv2.bitcoinaverage.com/exchanges/ticker/all?crypto=BTC,LTC&fiat=USD,EUR,GBP

    This will return price data from all exchanges for all combinations of markets: [BTCUSD, BTCEUR, BTCGBP, LTCUSD, LTCEUR, LTCGBP]

    Exchange Data, filtered by Symbol

    Example Request

    
    $ curl -H "X-testing: testing" https://apiv2.bitcoinaverage.com/exchanges/ticker/all?symbol={symbol}
    
    

    Example Response

    {
        "name": "coinbasepro",
        "display_name": "Coinbase Pro",
        "url": "https://www.coinbasepro.com/",
        "timestamp": 1497516426,
        "data_source": "api",
        "symbols": {
            "BTCUSD": {
                "last": 2448.08,
                "volume": 35068.96,
                "ask": 2448.08,
                "bid": 2446.56,
                "high": 2789.31,
                "low": 2210.00,
                "open": 2775.81
            }
        }
    },
    {
        "name": "btce",
        "display_name": "BTC-e",
        "url": "https://btc-e.com/",
        "timestamp": 1497516426,
        "data_source": "api",
        "symbols": {
            "BTCUSD": {
                "last": 2437.78,
                "volume": 13714.70,
                "ask": 2437.78,
                "bid": 2431.00,
                "high": 2704.00,
                "low": 2291.00,
                "vwap": 2497.50
            }
        }
    },
    

    Returns a list of all exchanges with their integrated symbols and data. Data can be filtered by symbol.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/exchanges/ticker/all?symbol={symbol}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    symbol False Full currency pair symbol. Example: BTCUSD

    Exchange Historical Data

    OHLC Historical data for specific market at an exchange.

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/exchanges/history/ohlc/bitstamp/BTCEUR
    
    

    Example Response

    {[
        {
            "time": "2020-02-22 00:00:00",
            "timestamp": 1582329600,
            "open": 8942.55,
            "high": 8964.53,
            "low": 8843.88,
            "close": 8926.81,
            "volume_crypto": 289.89384646,
            "volume_fiat": 2582681.6717429277,
            "weighted_price": 8909.06
        }, ...
    ]}
    

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/exchanges/history/ohlc/{exchange_name}/{market}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    exchange_name True Name of the exchange. Example: bitstamp
    market True Name of the market. Example: BTCUSD

    Exchange Orderbook snapshot

    We keep real time up-to-date orderbooks from the top exchanges: Coinbase, Binance, Bitstamp, Bitfinex, Kraken and Bittrex. This endpoint provides snapshots from these orderbooks.

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/exchanges/orderbook/coinbasepro/BTCUSD
    
    

    Example Response

    {
     "asks": [
            {
                "price": 9919.57,
                "amount": 1.84962619
            },
            {
                "price": 9919.58,
                "amount": 0.13
            },
            {
                "price": 9920,
                "amount": 0.001
            },
            {
                "price": 9920.13,
                "amount": 0.001
            },
            ...
        ],
      "bids": [
             {
                 "price": 9919.56,
                 "amount": 13.71937954
             },
             {
                 "price": 9917.72,
                 "amount": 4.2222365
             },
             {
                 "price": 9917.71,
                 "amount": 2.52062407
             },
             {
                 "price": 9917.1,
                 "amount": 1.1
             },
             ...
         ]
    }
    

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/exchanges/orderbook/{exchange_name}/{market}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    exchange_name True Name of the exchange. Example: bitstamp
    market True Name of the market. Example: BTCUSD

    Ignored Exchanges

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/exchanges/ignored
    
    

    Example Response

    [
        {
            "name": "cointrader",
            "display_name": "Cointrader",
            "url": "https://www.cointrader.net/",
            "timestamp": 1458755278,
            "ignore_reason": "Exchange has no daily volume"
        }
    ]
    

    Returns exchanges that are either ignored or inactive according to specified state parameter. With ignored exchanges the "ignore_reason" is provided.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/exchanges/{state}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    state True Filter with specific state. Options: ignored,inactive

    Exchange Count

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/exchanges/count
    
    

    Example Response

    {
        "included": 44,
        "ignored": 3,
        "count": 47,
        "success": true
    }
    

    Return a total of integrated exchanges along with ignored, included and inactive status counts

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/exchanges/count

    PERMISSIONS

    Exchange Outliers

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/exchanges/outliers
    
    

    Example Response

    {
        "last": {
            "BTCUSD": {
                "localbitcoins": 489.99
            },
            "BTCEUR": {
                "hitbtc": 452.0
            },
            "BTCCAD": {
                "localbitcoins": 586.59
            }
        },
        "bid": {
            "BTCUSD": {
                "independentreserve": 414.06
            },
            "BTCEUR": {
                "btcgreece": 367.87
            }
        },
        "ask": {
            "BTCUSD": {
                "bitkonan": 438.99
            }
        }
    }
    

    Returns a list of exchanges that failed our sanity checks. Provides what value failed and on what order book

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/exchanges/outliers

    PERMISSIONS

    Algorithm Weighting

    These endpoints return the weighting data that are used to calculate our various indices

    Indices Weighting

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/weighting/exchanges
    
    

    Example Response

    {
        "bit2c": {
            "BTCILS": 100.00
        },
        "bitbargain": {
            "BTCGBP": 9.00
        },
        "bitbay": {
            "BTCPLN": 87.00,
            "BTCEUR": 0.00
        },
        "bitcoin_co_id": {
            "BTCIDR": 100.00
        },
        "bitcoin_de": {
            "BTCEUR": 3.00
        },
        "bitcurex": {
            "BTCPLN": 12.00,
            "BTCEUR": 0.00
        },
    }
    

    Returns a list of exchanges, their symbols, and their associated weights

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/weighting/exchanges

    PERMISSIONS

    Currency Weights

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/weighting/currencies
    
    

    Example Response

    {
        "BTCUSD": {
            "market_share": 56.77
        },
        "BTCEUR": {
            "market_share": 25.81
        },
        "BTCHKD": {
            "market_share": 3.54
        },
        "BTCSGD": {
            "market_share": 2.37
        },
        "BTCRUB": {
            "market_share": 2.02
        },
        "BTCGBP": {
            "market_share": 1.87
        },
    }
    

    Returns a list of currencies and their weights that are used to produce our Global Bitcoin Price Index

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/weighting/currencies

    PERMISSIONS

    Price Conversion

    Converter

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/convert/global?from=BTC&to=USD&amount=2
    
    

    Example Response

    {
        "success": true,
        "time": "14-04-2016 13:55:32",
        "price": 424.93
    }
    

    Returns conversion from start currency to resulting currency. Only conversion from fiat to crypto, or vice verca are supported. Conversion from crypto to crypto is not supported.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/convert/{symbol_set}?from={source_cur}&to={target_cur}&amount={amount}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    symbol_set True Symbol Set. Options: global,local,crypto,tokens
    source_cur True Source currency code. Example: BTC
    target_cur True Target currency code. Example: USD
    amount False Amount of currency to convert. Example: 2

    Blockchain Tools

    Price Based on Transaction Hash

    Example Request

    
    $ curl https://apiv2.bitcoinaverage.com/blockchain/tx_price/BTCUSD/8a3b4394ba811a9e2b0bbf3cc56888d053ea21909299b2703cdc35e156c860ff
    
    

    Example Response

    {
      "time": "2016-05-17 00:00:00",
      "average": 457.91
    }
    

    Takes a transaction hash and returns a price for the day the transaction was conducted. The price is for the provided symbol.

    Currently this endpoint only supports BTC currency symbols.

    HTTP REQUEST

    GET https://apiv2.bitcoinaverage.com/blockchain/tx_price/{symbol}/{hash}

    PERMISSIONS

    URL PARAMETERS

    Parameter Required Description
    symbol True Full currency pair symbol. Example: BTCUSD
    hash True Valid transaction hash. Example: 8a3b4394ba811a9e2b0bbf3cc56888d053ea21909299b2703cdc35e156c860ff

    Websocket API

    Deprecated

    Overview

    The websocket feed provides real-time market data for price indices and exchanges.

    Root URL: wss://apiv2.bitcoinaverage.com/

    Authentication

    The procedure for authenticating websocket connections is the following:

    Step 1.

    Step 2.

    Notes.

    Channels

    After authentication is complete the websocket connection is established, you may then subscribe to the required channel.

    Available channels are listed below, they are single ticker, multiple ticker, single exchange and multiple exchanges.

    Single Ticker

    URL wss://apiv2.bitcoinaverage.com/websocket/ticker

    This channel returns data for one currency.

    Every time you send a new subscription message, the response data switches to the latest currency. You will always receive data only for the currency in your last subscription message.

    The unsubscribe message automatically closes the websocket connection.

    Example Subscribe Message

    {
        "event": "message",
        "data": {
            "operation": "subscribe",
            "options": {
                "currency": "BTCUSD",
                "symbol_set": "global"
            }
        }
    }
    

    Example Unsubscribe Message

    {
        "event": "message",
        "data": {
            "operation": "subscribe",
            "options": {
                "currency": "BTCUSD",
                "symbol_set": "global"
            }
        }
    }
    

    Example Response

    {
        "event": "message", 
        "data": {
            "ask": 3794.37, 
            "bid": 3788.77, 
            "last": 3792.99, 
            "high": 3886.24, 
            "low": 3646.44, 
            "open": {
                "day": 3207.15, 
                "week": "", 
                "month": ""
            }, 
            "averages": {
                "day": 3858.24, 
                "week": 3638.93,
                "month": 3551.50
            }, 
            "volume": 91647.05917798, 
            "changes": {
                "percent": {
                    "day": 18.27, 
                    "week": "", 
                    "month": ""
                }, 
                "price": {
                    "day": 585.84, 
                    "week": "", 
                    "month": ""
                }
            }, 
            "volume_percent": 17.372942071735917, 
            "timestamp": 1504088398, 
            "display_timestamp": "2017-08-30 10:19:58", 
            "success": true, 
            "time": "2017-08-30 10:20:02"
        }
    }
    
    

    Multiple Ticker

    URL wss://apiv2.bitcoinaverage.com/websocket/multiple/ticker

    This channel returns data for multiple currencies. They are grouped by their market, local, global, crypto and tokens.

    Every time you send a new subscription message, the requested currency is added to the response.

    The unsubscribe message does not close the websocket connection but only removes the unsubscribed currency from the response.

    Example Subscribe Message

    {
        "event": "message",
        "data": {
            "operation": "subscribe",
            "options": {
                "currency": "BTCUSD",
                "symbol_set": "global"
            }
        }
    }
    

    Example Unsubscribe Message

    {
        "event": "message",
        "data": {
            "operation": "unsubscribe",
            "options": {
                "currency": "BTCUSD",
                "symbol_set": "global"
            }
        }
    }
    

    Example Response

    {
        "event": "message",
        "data":{
            "local": {
                "BTCUSD": {...data},
                "ETHEUR": {...data},
                ...
                },
            "global":{
                "BTCGBP": {...data},
                "BCHCAD": {...data},
                ...
            }
        }
    }
    

    Single Exchange

    URL wss://apiv2.bitcoinaverage.com/websocket/exchanges

    This channel returns data for one exchange.

    Every time you send a new subscription message, the response data switches to the latest exchange. You will always receive data only for the exchange in your last subscribe message.

    The unsubscribe message will automatically close the websocket connection

    Example Subscribe Message

    {
        "event": "message",
        "data": {
            "operation": "subscribe",
            "options": {
                "exchange": "bitstamp",
            }
        }
    }
    

    Example Unsubscribe Message

    {
        "event": "message",
        "data": {
            "operation": "unsubscribe",
            "options": {
                "exchange": "bitstamp",
            }
        }
    }
    

    Example Response

    {
        "event": "message", 
        "data": {
            "name": "bitstamp", 
            "display_name": "Bitstamp", 
            "url": "https://bitstamp.net/", 
            "timestamp": 1504089517, 
            "data_source": "api", 
            "symbols": {
                "BTCUSD": {
                    "last": 4521.00000000, 
                    "volume": 13804.66498165, 
                    "ask": 4520.99000000, 
                    "bid": 4516.00000000, 
                    "high": 4649.78000000, 
                    "low": 4352.00000000, 
                    "open": 4578.82000000, 
                    "vwap": 4552.56000000
                }, 
                "BTCEUR": {
                    "last": 3791.68000000, 
                    "volume": 1828.26480131, 
                    "ask": 3791.50000000, 
                    "bid": 3785.66000000, 
                    "high": 3845.00000000, 
                    "low": 3586.38000000, 
                    "open": 3818.06000000, 
                    "vwap": 3766.39000000
                }, 
                "XRPUSD": {
                    "last": 0.22000000, 
                    "volume": 13810294.23579809, 
                    "ask": 0.22000000, 
                    "bid": 0.21971000, 
                    "high": 0.22600000, 
                    "low": 0.21500000, 
                    "open": 0.21994000, 
                    "vwap": 0.22074000
                }, 
                "XRPEUR": {
                    "last": 0.18489000, 
                    "volume": 5471715.21778042, 
                    "ask": 0.18544000, 
                    "bid": 0.18405000, 
                    "high": 0.18831000, 
                    "low": 0.17761000, 
                    "open": 0.18320000, 
                    "vwap": 0.18401000
                }
            }, 
            "success": true, "time": "2017-08-30 10:38:49"
        }
    }
    

    Multiple Exchanges

    URL wss://apiv2.bitcoinaverage.com/websocket/multiple/exchanges

    This channel returns data for multiple exchanges.

    Every time you send a new subscription message, the requested exchange is added to the response.

    The unsubscribe message does not close the websocket connection here but only removes the unsubscribed exchange from the response.

    Example Subscribe Message

    {
        "event": "message",
        "data": {
            "operation": "subscribe",
            "options": {
                "exchange": "bitstamp",
            }
        }
    }
    

    Example Unsubscribe Message

    {
        "event": "message",
        "data": {
            "operation": "unsubscribe",
            "options": {
                "exchange": "bitstamp",
            }
        }
    }
    

    Example Response

    {
        “event": "message",
        “data": {
            "success":true, 
            "time”: "2017-08-30 10:46:10",
                "bitstamp": {...data},
                "bitfinex": {...data},
                ...
            }
        }
    }
    

    Websocket API V2

    Deprecated

    Overview

    Version 2 of our Websocket API that pushes realtime updates as soon as they happen instead on a set interval of seconds, depending on your plan.

    This allows for faster updates with less bandwidth because we push updates of only the prices that have changed.

    Root URL: wss://apiv2.bitcoinaverage.com/websocket/v2

    Client Limits

    Our Websocket API V2 is available to Grow and Dominate plans and our legacy Enterprise clients.

    Data Frequency

    Updates are pushed in real time, so they depend on the activity of the markets. For activelly traded cryptocurrencies like Bitcoin and Ethereum this could be less than a second, but for more obscure cryptocurrencies it could be minutes appart.

    Authentication

    The procedure for authenticating these websocket connections is the same as in version 1 except the urls are changed.

    Step 1.

    Step 2.

    Notes.

    Channels

    After authentication is complete the websocket connection is established, you may then send your subscription message to the channel.

    There are two channels, ticker and exchanges, that can be used to connect to one or more indices or exchanges respectively.

    Ticker

    URL wss://apiv2.bitcoinaverage.com/websocket/v2/ticker

    This channel returns ticker data for multiple symbols grouped in symbol sets. The symbols sets are local, global, crypto and tokens. Every time you send a new subscription message, the new symbols are added to the response in their symbol set. The unsubscribe message does not close the connect but removes symbols from the response.

    Example Subscribe Message

    {
        "event": "message",
        "data": {
            "operation": "subscribe",
            "options": {
                "currency_list": ["BTCUSD", "BTCGBP", "ETHUSD"],
                "symbol_set": "global"
            }
        }
    }
    

    Example Unsubscribe Message

    {
        "event": "message",
        "data": {
            "operation": "unsubscribe",
            "options": {
                "currency_list": ["BTCUSD"],
                "symbol_set": "global"
            }
        }
    }
    

    Example Response

    {
        "event": "message",
        "data":{
            "local": {
                "BTCUSD": {...data},
                "ETHEUR": {...data},
                ...
                },
            "global":{
                "BTCGBP": {...data},
                "BCHCAD": {...data},
                ...
            }
        }
    }
    

    Exchanges Price Data

    URL wss://apiv2.bitcoinaverage.com/websocket/v2/exchanges

    This channel returns data for multiple exchanges. Every time you send a new subscription message, the requested exchanges are added to the response.

    The unsubscribe message does not close the websocket connection but only removes the unsubscribed exchanges from the response.

    Example Subscribe Message

    {
        "event": "message",
        "data": {
            "operation": "subscribe",
            "options": {
                "exchange_list": ["bitstamp", "bitfinex"],
            }
        }
    }
    

    Example Unsubscribe Message

    {
        "event": "message",
        "data": {
            "operation": "unsubscribe",
            "options": {
                "exchange_list": ["bitstamp"],
            }
        }
    }
    

    Example Response

    {
        “event": "message",
        “data": {
            "bitstamp": {...data},
            "bitfinex": {...data},
            ...
        }
    }
    
    

    Websocket API V3

    Overview

    Websocket API version 3 that focuses on offering higher availability and uptime than version 2.

    Our Websocket API pushes realtime updates as soon as they happen instead on a set interval of seconds.

    This allows for faster updates with less bandwidth because we push updates of only the prices that have changed.

    Root URL: wss://apiv2.bitcoinaverage.com/websocket/v3

    Client Limits

    Our Websocket API V3 is available to Grow and Dominate plans.

    Plan Connections limit Ticker symbols Exchanges symbols
    Grow 10 100 200
    Dominate 20 300 500

    Data Frequency

    Updates are pushed in real time, so they depend on the activity of the markets. For actively traded cryptocurrencies like Bitcoin and Ethereum this could be less than a second, but for more obscure cryptocurrencies it could be minutes apart.

    Authentication

    Step 1.

    Step 2.

    Notes.

    Channels

    After the websocket connection is established you may send your subscription message to specify the channel and the subscription options.

    There are 4 channels: ticker, exchanges, orderbooks and tradebooks.

    Ticker

    This channel returns ticker data for multiple symbols grouped in symbol sets.

    The symbols sets are local, global, crypto and tokens.

    You can check which cryptocurrency markets belong in which symbol set here: https://apiv2.bitcoinaverage.com/constants/indices/ticker/symbols/

    Every time you send a new subscription message, the new symbols are added to the response in their symbol set.

    The unsubscribe message does not close the connection but removes symbols from the response.

    Example Subscribe Message

    {
        "event": "message",
        "data": {
            "channel": "multiple-ticker",
            "operation": "subscribe",
            "options": {
                "currency_list": ["BTCUSD", "BTCGBP", "ETHUSD"],
                "symbol_set": "global"
            }
        }
    }
    

    Example Unsubscribe Message

    {
        "event": "message",
        "data": {
            "channel": "multiple-ticker",
            "operation": "unsubscribe",
            "options": {
                "currency_list": ["BTCUSD"],
                "symbol_set": "global"
            }
        }
    }
    

    Example Response

    {
        "event": "message",
        "data":{
            "local": {
                "BTCUSD": {...data},
                "ETHEUR": {...data},
                ...
                },
            "global":{
                "BTCGBP": {...data},
                "BCHCAD": {...data},
                ...
            }
        }
    }
    

    Exchanges Price Data

    This channel returns data for multiple exchanges symbols. Every time you send a new subscription message, the requested exchanges symbols are added to the response.

    The unsubscribe message does not close the websocket connection but only removes the unsubscribed symbols from the response.

    Example Subscribe Message

    {
        "event": "message",
        "data": {
            "channel": "multiple-exchanges",
            "operation": "subscribe",
            "options": {
                "exchange": ["coinbasepro"],
                "currency_list": ["BTCUSD", "ETHUSD", "BCHUSD"]
            }
        }
    }
    

    Example Unsubscribe Message

    {
        "event": "message",
        "data": {
            "channel": "multiple-exchanges",
            "operation": "unsubscribe",
            "options": {
                "exchange": ["bitstamp"],
                "currency_list": ["BTCUSD"]
            }
        }
    }
    

    Example Response

    {
        “event": "message",
        “data": {
            "bitstamp": {
                "BTCUSD": {...data},
                "ETHUSD": {...data},
            },
            "coinbasepro": {
                "LTCUSD": {...data},
            },
            ...
        }
    }
    
    

    Exchanges Orderbook Data

    This channel returns orderbook data for one or more symbols from a single exchange.

    Example Subscribe Message

    {
        "event": "message",
        "data": {
            "channel": "orderbooks",
            "operation": "subscribe",
            "symbols": ["BTCUSD", "BTCEUR"],
            "exchange": "coinbasepro"
        }
    }
    

    Example Unsubscribe Message

    {
        "event": "message",
        "data": {
            "operation": "unsubscribe",
            "symbols": ["ETHBTC", "LTCBTC"],
            "exchange": "binance",
        }
    }
    

    The first response this channel provides is a snapshot of the current state of the orderbook.

    Snapshot Response

    {
        “event": "message",
        “data": {
            bids: [sorted array of buy orders (sorted descending)],
            asks: [sorted array of sell orders (sorted ascending)],
            symbol: "BTCUSD",
            type: "snapshot"
        }
    }
    

    Order format

    {
        price: 8100,
        amount: 1.9384
    }
    

    After the snapshot is sent, the channel will continue sending update events that represent the changes in the orderbook.

    Update Response

    {
        symbol: "BTCUSD",
        updates: [array of updated orders],
        type: "update
    }
    

    Update order format

    {
      side: "bids",
      price: 8100,
      amount: 1,
    }
    

    Every updated order in the updates field has the following format. The side value can be bids or asks representing the array where this order is located. The amount is greater or equal to 0. If it is 0, then the order has been completed and is no longer part of the orderbook. If it is greater than 0 then this is the new amount for the given price and needs to be updated in the orderbook.

    Keeping an up-to-date orderbook

    Keeping an up-to-date orderbook

    const ba = require('bitcoinaverage');
    
    var publicKey = 'yourPublicKey';
    var secretKey = 'yourSecretKey';
    var wsClient = ba.websocketClient(publicKey, secretKey);
    
    var symbols = ['BTCUSD', 'ETHUSD'];
    var exchange = 'bitfinex';
    var ORDERBOOKS = {
        BTCUSD: {},
        ETHUSD: {}
    };
    var symbol = '';
    var i, item;
    wsClient.connectToOrderbookWebsocket(exchange, symbols, function(response){
        symbol = respnose.data.symbol;
        if(response.data.type === "snapshot"){
            for (var i = 0; i < response.data.asks.length; i++){
              item = response.data.asks[i];
              ORDERBOOKS[symbol].asks[item.price] = item;
            }
            for (var j = 0; j < response.data.bids.length; j++){
              item = response.data.bids[i];
              ORDERBOOKS[symbol].bids[item.price] = item;
            }
         }else{
           for (var i = 0; i < response.data.updates.length; i++){
              var item = response.data.updates[i];
             if(item.amount === 0){
                delete(ORDERBOOKS[symbol][item.side][item.price]);
             }else{
               ORDERBOOKS[symbol][item.side][item.price] = item;
             }
           }
         }
    }, function(err){
    console.log(err);
    });
    

    The process of keeping an orderbook is quite straightforward:

    1. Connect to the orderbook channel (our npm package makes this easier).
    2. If the response is of type snapshot then store the arrays of bids(buy orders) and asks(sell orders).
    3. Otherwise the respnose is of type update. Iterate the update array from the response and update the orderbook.
    4. If the amount is 0 then remove that price level from the orderbook.
    5. If the amount is greater than 0 then update the price level.

    In this example we're using our npm package that can be installed with: npm install bitcoinaverage

    Exchanges Trade Data

    This channel returns trade data for one or more symbols from a single exchange.

    Example Subscribe Message

    {
        "event": "message",
        "data": {
            "channel": "tradebooks",
            "operation": "subscribe",
            "currency_list": ["BTCUSD", "BTCEUR"],
            "exchange": "coinbasepro"
        }
    }
    

    Example Unsubscribe Message

    {
        "event": "message",
        "data": {
            "operation": "unsubscribe",
            "currency_list": ["ETHBTC", "LTCBTC"],
            "exchange": "binance",
        }
    }
    

    After your subscription message you will start receiving trade updates in the following format.

    Trade update Response

    [ { id: 12341234,
           time: 1572243089130,
           amount: '0.12213193',
           price: '183.92',
           type: 'sell',
           symbol: 'ETHUSD'
      },
      ...
    ]
    

    Errors

    The BitcoinAverage API uses the following error codes:

    Error Code Meaning
    400 Bad Request -- Incorrectly formatted request
    401 Unauthorized -- An issue with Authentication
    403 Forbidden -- Higher level API Keys required
    404 Not Found -- Incorrect endpoint URL
    429 Too Many Requests -- You're requesting too often, upgrade your API Keys.
    500 Internal Server Error -- We had a problem with our server. Try again later.
    503 Service Unavailable -- We're temporarily offline. Please try again later.