market:dex:ohlcv

Subscribes to Decentralized exchange market Open High Low Close Volume, optionally filtered by exchange or pair.

👍

Protocols Supported

This subscription only supports Uniswap v2, Uniswap v3, Sushiswap and Uniswap clones.

👍

Blockchains Supported

This subscription only supports data on ethereum-mainnet.

Make sure you're connected.

Request

All pairs:

{
  "jsonrpc" : "2.0",
  "id"      : 1,
  "method"  : "subscribe",
  "params"  : [ "market:dex:ohlcv" ]
}

Specific pair or exchange:

{
  "jsonrpc" : "2.0",
  "id"      : 1,
  "method"  : "subscribe",
  "params"  : [ "market:dex:ohlcv", { "exchange": "0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f" } ]
}
ParamTypeDescription
pairstringThe asset pair by which to filter. DEX pairs are most accurate using pair contract address rather than symbols (OPTIONAL)
exchangestringThe exchange for which to retrieve asset pairs. (OPTIONAL)

Response

"result": [{
  "timestamp":"2021-01-29T00:12:00.000Z",
  "exchange":"0xc0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac",
  "pair":"0xfb3cd0b8a5371fe93ef92e3988d30df7931e2820",
  "open":"160.00500189413906877164",
  "high":"160.00500189413906877164",
  "low":"160.00500189413906877164",
  "close":"160.00500189413906877164",
  "volume":"579.605525927946992761",
  "trades":1
}]
FieldTypeDescription
exchangestringThe exchange contract address.
timestampnumberThe time at which the trade took place.
pairstringThe pair contract address.

Example

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

ws.on('open', () => {
  ws.send(JSON.stringify({
      jsonrpc: '2.0',
      method: 'subscribe',
      params: ['market:dex:ohlcv'],
      id: 1,
    }));
});

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