market:dex:ohlcv [ENT]

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

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" } ]
}

Param

Type

Description

pair

string

The asset pair by which to filter. DEX pairs are most accurate using pair contract address rather than symbols (OPTIONAL)

exchange

string

The 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
}]

Field

Type

Description

exchange

string

The exchange contract address.

timestamp

number

The time at which the trade took place.

pair

string

The 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));
});