market:spot:tickers [ENT]

Subscribes/Unsubscribes to market ticker data.

Make sure you're connected. Either the pair or exchange have to be specified - one needs to be specified, but both cannot be empty.
Note that there is a dedicated URL for this subscription: wss://ws.web3api.io/spot.

Request

{
  "jsonrpc" : "2.0",
  "id"      : 1,
  "method"  : "subscribe",
  "params"  : [ "market:spot:tickers", { "pair": "eth_btc", "exchange": "gdax" } ]
}

Param

Type

Description

pair

string

The asset pair.

exchange

string

The exchange for which to retrieve asset pairs.

Response

"result": {
  "exchange": "gdax",
  "pair": "eth_btc",
  "exchangeTimestamp": 1561495569991,
  "exchangeTimestampNanoseconds": 0,
  "timestamp": 1561495560000,
  "bid": 0.02713,
  "ask": 0.02715,
  "mid": 0.02714,
  "last": 0.02715
}

Field

Type

Description

exchange

string

The exchange.

timestamp

number

The time at which the trade took place.

timestampNanoseconds

number

The nano second part of the timestampMilliseconds, where applicable.

Example

const WebSocket = require('ws');
const ws = new WebSocket('wss://ws.web3api.io/spot', {headers: {x-api-key:'<api_key>'}});

ws.on('open', () => {
  ws.send(JSON.stringify({
      jsonrpc: '2.0',
      method: 'subscribe',
      params: ['market:spot:tickers', {'pair': 'eth_btc', 'exchange': 'gdax'}],
      id: 1,
    }));
});

ws.on('message', data => {
  console.log(JSON.stringify(JSON.parse(data), null, 2));
});