ViteX WebSocket API Base Endpoint [MainNet] wss://api.vitex.net/v2/ws
Quick Start
Copy
npm install -g wscat
wscat -c wss://api.vitex.net/v2/ws
> { "command" : "ping" }
< { "code" :0,"event" : "pong" ,"timestamp" :1635682990916}
> { "command" : "sub" , "params" : [ "market.VITE_BTC-000.trade" ] }
< { "code" :0,"event" : "sub" ,"topic" : "[market.VITE_BTC-000.trade]" }
< { "code" :0,"data" :[ { "a" : "0.00018200" ,"bf" : "0.00000045" ,"bh" :48524712,"bid" : "00000401000000000000001bc56000617e877c00001a" ,"id" : "6473c6cc1ebc0031053963a4f73c0daf245cde9c" ,"p" : "0.00000182" ,"q" : "100.0" ,"qid" : "tti_b90c9baffffc9dae58d1f33f" ,"qs" : "BTC-000" ,"s" : "VITE_BTC-000" ,"sf" : "0.00000045" ,"sid" : "00000400ffffffffffffffe43a9f00617e645f000012" ,"side" :1,"t" :1635682226,"tid" : "tti_5649544520544f4b454e6e40" ,"ts" : "VITE" } ] ,"event" : "push" ,"timestamp" :1635682227087,"topic" : "market.VITE_BTC-000.trade" }
Message Patterns Request Messages
Copy
{
"command" : "sub" ,
"params" : [ "market.VX_VITE.depth" ]
}
Response Messages
Copy
{
"code" : 0 ,
"event" : "push" ,
"timestamp" : 1635659587885 ,
"topic" : "market.VX_VITE.depth" ,
"data" : { ...}
}
Commands and Events sub : subscribe to a topic un_sub : un-subscribe from a topic ping : keep-alive heartbeat message pong : keep-alive heartbeat acknowledgement push : data pushed to the client Keep Alive Important
To keep sessions alive, ping
heartbeat messages should be sent every 10 seconds and no longer than 1 minute at most. When heartbeats are sent later than 1 minute, the client is not regarded as alive anymore and registered subscriptions will be cleaned up.
Subscribe Topics Topic Description Message order.$address
Order update Order
market.$symbol.depth
Depth data update Depth
market.$symbol.trade
Trade data update Trade
market.$symbol.tickers
Market pair statistics update TickerStatistics
market.quoteToken.$symbol.tickers
Quote token statistics update TickerStatistics
market.quoteTokenCategory.VITE.tickers
Quote token category statistics update TickerStatistics
market.quoteTokenCategory.ETH.tickers
Quote token category statistics update TickerStatistics
market.quoteTokenCategory.USDT.tickers
Quote token category statistics update TickerStatistics
market.quoteTokenCategory.BTC.tickers
Quote token category statistics update TickerStatistics
market.$symbol.kline.minute
1-minute candlestick chart (aka kline) update Kline
market.$symbol.kline.minute30
30-minute candlestick chart (aka kline) update Kline
market.$symbol.kline.hour
1-hour candlestick chart (aka kline) update Kline
market.$symbol.kline.day
1-day candlestick chart (aka kline) update Kline
market.$symbol.kline.week
1-week candlestick chart (aka kline) update Kline
market.$symbol.kline.hour6
6-hour candlestick chart (aka kline) update Kline
market.$symbol.kline.hour12
12-hour candlestick chart (aka kline) update Kline
Push Message Definitions Push messages will be sent to the client continually after successsfully subscribing to a topic.
Push Message Pattern
Copy
{
"code" : 0 ,
"event" : "push" ,
"timestamp" : 1635659587885 ,
"topic" : "market.VX_VITE.depth, market.BTC-000_VITE.depth" ,
"data" : { ...}
}
Order
Copy
// order id
private String oid;
// symbol
private String s;
// trade token symbol
private String ts;
// quote token symbol
private String qs;
// trade tokenId
private String tid;
// quote tokenId
private String qid;
// side
private Integer side;
// price
private String p;
// quantity
private String q;
// amount
private String a;
// executed quantity
private String eq;
// executed amount
private String ea;
// executed percentage
private String ep;
// executed average price
private String eap;
// fee
private String f;
// status
private Integer st;
// type
private Integer tp;
// create time
private Long ct;
// address
private String d;
Trade
Copy
// tradeId
private String id;
// symbol
private String s;
// trade token symbol
private String ts;
// quote token symbol
private String qs;
// trade tokenId
private String tid;
// quote tokenId
private String qid;
// price
private String p;
// quantity
private String q;
// amount
private String a;
// time
private Long t;
// side: 0-buy, 1-sell
private Integer side;
// buyer orderId
private String bid;
// seller orderId
private String sid;
// buyer fee
private String bf;
// seller fee
private String sf;
// block height
private Long bh;
Ticker Statistics
Copy
// symbol
private String s;
// trade token symbol
private String ts;
// quote token symbol
private String qs;
// trade tokenId
private String tid;
// quote tokenId
private String qid;
// open price
private String op;
// previous close price
private String pcp;
// close price
private String cp;
// price change
private String pc;
// price change percentage
private String pCp;
// high price
private String hp;
// low price
private String lp;
// quantity
private String q;
// amount
private String a;
// price precision
private Integer pp;
// quantity precision
private Integer qp;
Candlestick Chart (aka Kline)
Copy
private Long t; // timestamp in seconds
private Double c; // close price
private Double o; // open price
private Double v; // volume
private Double h; // high price
private Double l; // low price
Depth
Copy
private List<List<String>> asks; // [[price, quantity],[price, quantity]]
private List<List<String>> bids; // [[price, quantity],[price, quantity]]