market:dex:vwap

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

Make sure you're connected.

Request

All pairs:

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

Specific pair or exchange:

{
  "jsonrpc":"2.0",
  "id":1,
  "method":"subscribe",
  "params":[
    "market:dex:vwap",
    {"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":"9.40940773086296676040",
  "delistedPair":false,
  "isNewPair":false,
  "pair":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2_0xdac17f958d2ee523a2206206994597c13d831ec7",
  "previousPrice":"3730.87599831862126944094",
  "previousTimestamp":"2021-12-30T21:51:00.000Z",
  "price":"3740.28540604948423620134",
  "vwap":"3737.07857648767941608106314093",
  "timestamp":"2021-12-30T21:52:00.000Z",
  "unchangedPrice":false
}
FieldTypeDescription
delistedPairbooltrue if pair has been delisted. false otherwise.
deltanumberThe dollar value 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.
vwapnumberThe VWAP value.
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:vwap"],
      id: 1,
    }));
});

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