Skip to content

WebSocket /route/subscribe

wss://router.intear.tech/route/subscribe

A WebSocket that sends quotes for a request and keeps sending new ones as pools change. See Live quotes for a walkthrough.

All messages are JSON in text frames. Non-text frames from the client are ignored.

{ "id": 1, "query": "token_in=near&token_out=usdt.tether-token.near&amount_in=1000000000000000000000000&max_wait_ms=2000&slippage_type=Fixed&slippage=0.01" }
Field Type Description
id unsigned integer Your ID for this request, sent back with each update
query string, optional Same query string as GET /route. If missing, the current request is stopped and nothing new starts

Each message replaces the previous request. A message that isn’t valid JSON of this shape closes the connection.

Quotes for a request:

{ "id": 1, "routes": [ ... ] }

routes is an array of quote objects, best first, same as GET /route. The first one is sent as soon as routes are found. After that, one is sent each time pools update and the quotes change.

An error for a request:

{ "id": 1, "error": "Slippage must be between 0.00 and 1.00" }

Sent instead of quotes when the query is invalid. The connection stays open. Error texts are the same as for GET /route, without the HTTP status.

After each round of routing, the server waits about 10× as long as routing took, at most 3 seconds, then routes again on the next pool update. In practice this means an update every block or every few blocks while the pools are active.