> ## Documentation Index
> Fetch the complete documentation index at: https://docs.raze.bot/llms.txt
> Use this file to discover all available pages before exploring further.

# Quote stream

> A live quote pushed when the pools of its route change: WebSocket or SSE, the same fields as GET /quote.

A client that shows a live price for an amount already typed (a buy panel, a sell button) does not need to poll `/quote`. `GET /quote/stream` keeps the question open and the router answers it again whenever an account of the route it served is written: the pool, or one of its vaults. A quiet pool sends no change-driven updates; a busy one sends at most one quote per pacing interval.

Every quote is the one `GET /quote` would answer at that moment, made by the same code, and its body travels unchanged as `data`: parse it as you parse `/quote`, and build it with `POST /swap-instructions` like any other quote.

> [!NOTE]
>
> Opening a connection uses one request from the key’s rate limit. Billing is per started minute the WebSocket or SSE connection stays open (`router / stream_minute`), even when idle. There is no separate charge for opening it or for individual quotes.

## WebSocket

Open `wss://router.raze.bot/quote/stream` (with the API key) and send JSON text frames.

| You send | Meaning |
| - | - |
| `{"op":"subscribe","id":"s1", …the fields of GET /quote…}` | Ask a question. `id` is yours; `minIntervalMs` (optional) slows its pushes down, never below the router's floor (150 ms) and never above 5 s. A `subscribe` on a live `id` replaces it: that is how you change the amount. |
| `{"op":"unsubscribe","id":"s1"}` | Stop it. |
| `{"op":"ping"}` | The router answers `{"op":"pong"}`. |

| You receive | Meaning |
| - | - |
| `{"op":"subscribed","id":"s1"}` | The subscription is live; its first quote follows. |
| `{"op":"quote","id":"s1","seq":3,"slot":…,"data":{…}}` | A quote: `data` is the body of `GET /quote`. |
| `{"op":"no_quote","id":"s1","seq":4,"slot":…,"status":422,"data":{…}}` | No quote this time: `status` and `data` are what `GET /quote` would answer (`404` no route, `422` a decline, `503` not ready). The subscription stays and tries again, except after a `400`: a wrong question is answered once and the subscription ends. |
| `{"op":"unsubscribed","id":"s1"}` | Done. |
| `{"op":"error","id":"s1","message":…}` | A frame the router could not take: bad JSON, too many subscriptions on the connection (16), the router at its capacity. |

`seq` grows by one per frame of a subscription. A quote that changes nothing you can see (amounts, route, fees) is not sent again, except once every 5 seconds, so a flat price and a dead stream look different. Without any write on its route a subscription is quoted again every second anyway, so the route can move to a pool it was not watching.

```js theme={null}
const ws = new WebSocket("wss://router.raze.bot/quote/stream?apiKey=" + KEY);
ws.onopen = () => ws.send(JSON.stringify({
  op: "subscribe", id: "buy",
  inputMint: "So11111111111111111111111111111111111111112",
  outputMint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  amount: "100000000", slippageBps: 50,
}));
ws.onmessage = (m) => {
  const f = JSON.parse(m.data);
  if (f.op === "quote") render(f.data);           // the GET /quote body
  if (f.op === "no_quote") showReason(f.status, f.data);
};
```

## Server-sent events

Without the WebSocket upgrade, `GET /quote/stream` with the query of `GET /quote` (plus `minIntervalMs`) is one subscription as an event stream. Each event is named after its `op` (`quote`, `no_quote`) and carries the same JSON as the WebSocket frame.

```bash theme={null}
curl -N "$ROUTER/quote/stream?inputMint=$SOL&outputMint=$USDC&amount=100000000&slippageBps=50" \
  -H "x-api-key: $KEY"
```

A malformed query is `400` before the stream opens; the router at its capacity is `503 stream_capacity`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.