market:dex:prices [ENT]

Subscribes to Decentralized exchange market prices, optionally filtered by exchange or pair.

Make sure you're connected.

Request

All pairs:

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

Specific pair or exchange:

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

Response

"result": {
  "delta":"-0.00608075655281506397",
  "delistedPair":false,
  "isNewPair":false,
  "pair":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2_0xfa5047c9c78b8877af97bdcb85db743fd7313d4a",
  "previousPrice":"3.57799516690081739647",
  "previousTimestamp":"2021-01-29T00:35:00.000Z",
  "price":"3.5719144103480023325",
  "timestamp":"2021-01-29T00:38:00.000Z",
  "unchangedPrice":false
}
FieldTypeDescription
delistedPairbooltrue if pair has been delisted. false otherwise.
deltanumberThe change in price since last update.
isNewPairbooltrue if pair is new. false otherwise.
pairstringThe pair, using both base addresses of the pair underlying assets.
previousPricetimestampThe price at time of last update.
previousTimestamptimestampThe time of the last update.
pricenumberThe quote price of the asset pair.
timestampnumberThe time at which the price change took place.
unchangedPricebooltrue if price hasn't changed since last update. false otherwise.

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:prices"],
      id: 1,
    }));
});

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