Orders and live data
Live prices (WebSocket)
/v1/ws/prices pushes USDC prices as soon as a pool on a token's path moves. Use it instead of polling /v1/price.
Protocol
-
Open a WebSocket to
ws(s)://<host>/v1/ws/prices. -
Send one JSON message with up to 100 ids:
{ "subscribe": ["HYPE", "0x7D29d8047B905000459c0E80c34a26CeedcB47b2", "0xD089…"] } -
The server answers at once with every price:
{ "prices": { "HYPE": 24.81, "0x7D29…": 1.0, "0xD089…": 0.00231 } } -
Then, after each indexed block, it sends only the prices that changed:
{ "prices": { "0xD089…": 0.00233 } }
Send a new subscribe at any time to replace the list. A malformed message gets { "error": "send {\"subscribe\": [\"HYPE\", \"0x…\"]}" }.
Example
const ws = new WebSocket("wss://api.lane.markets/v1/ws/prices");
ws.onopen = () => ws.send(JSON.stringify({ subscribe: ["HYPE", USDC, PERPME] }));
ws.onmessage = (e) => {
const msg = JSON.parse(e.data);
if (msg.prices) Object.assign(prices, msg.prices);
};What a price is
- USDC per whole token, at spot (no size impact), net of LP fees, along the best route found in memory.
nullif there is no route to USDC.HYPEis the best of the allow-listed WHYPEs (they're 1:1 through the rewrap).- Computed from the indexer's state: no RPC call, so it's cheap to subscribe to many tokens.
A price is a reference for display and for limits; the amount you get on a trade comes from /v1/quote.
When updates are sent
After each sync, the server collects the tokens of every pool that changed. A subscribed token is recomputed if it's in that set, or if a WHYPE or USDC pool moved (they're on almost every path). Only changed values are sent. With WS_URL configured on the server, that's within a second of the block; with polling, within POLL_MS.
Next: Portfolio and history