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

# Quote Stream

> Stream live bid/ask quotes for token pairs over WebSocket

The `quote-stream` endpoint streams a live bid and ask for a pair of token mints.
See [Market Data Streams](/spot/trading/market-data-streams) for what the quotes
mean and when to use the stream; this page documents the message format.

<Info>
  Quotes are **approximations** across **direct and one-hop** routes, computed
  from a \$10 USDC equivalent round-trip trade. They can differ from the quote you
  receive at order time.
</Info>

<Note>
  Access to the quote stream is gated. Reach out to the team to request access.
</Note>

## Connection

See the [Websockets Overview](/resources/trading-api/websockets/overview#connection)
for endpoint details.

## Subscribe

Send a `subscribe` op with the base and quote mints:

```json theme={null}
{
  "op": "subscribe",
  "base_mint": "So11111111111111111111111111111111111111112",
  "quote_mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
}
```

## Unsubscribe

```json theme={null}
{
  "op": "unsubscribe",
  "base_mint": "So11111111111111111111111111111111111111112",
  "quote_mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
}
```

## Message Format

Each message is a batch covering one slot:

```json theme={null}
{
  "u": 425218378,
  "ts": 1780964565,
  "subscribe": [
    {
      "sb": "So11111111111111111111111111111111111111112",
      "sq": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "auto": false
    }
  ],
  "updates": [
    {
      "sb": "So11111111111111111111111111111111111111112",
      "sq": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "b": "66.46416041",
      "B": "9.99791400",
      "a": "66.46410253",
      "A": "9.99791400"
    }
  ]
}
```

### Fields

| Field                       | Type   | Description                              |
| --------------------------- | ------ | ---------------------------------------- |
| `u`                         | number | Slot the quotes were computed at         |
| `ts`                        | number | Unix timestamp in seconds                |
| `updates`                   | array  | Per-pair quote updates for this slot     |
| `subscribe` / `unsubscribe` | array  | Acknowledgements of subscription changes |

Each entry in `updates` has:

| Field | Type   | Description                                                                                         |
| ----- | ------ | --------------------------------------------------------------------------------------------------- |
| `sb`  | string | Base mint                                                                                           |
| `sq`  | string | Quote mint                                                                                          |
| `b`   | string | Bid price, quote per base, 8 decimals                                                               |
| `a`   | string | Ask price, quote per base, 8 decimals                                                               |
| `B`   | string | Bid size, quote-denominated (\$10 USDC equivalent)                                                  |
| `A`   | string | Ask size, quote-denominated                                                                         |
| `e`   | string | Per-pair error code (for example `no_route`), present instead of prices when a quote is unavailable |

## Code Examples

<AccordionGroup>
  <Accordion title="Subscribe to a Pair">
    ```typescript theme={null}
    // Dev endpoint — no API key required, but rate-limited.
    // For production, use your production WS URL and add
    // { headers: { "x-api-key": "YOUR_API_KEY" } } as the second arg to new WebSocket().
    const WS_URL = "wss://dev-quote-api.dflow.net/quote-stream";

    const SOL = "So11111111111111111111111111111111111111112";
    const USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";

    const ws = new WebSocket(WS_URL);

    ws.onopen = () => {
      ws.send(JSON.stringify({ op: "subscribe", base_mint: SOL, quote_mint: USDC }));
    };

    ws.onmessage = (event) => {
      const frame = JSON.parse(event.data);
      for (const u of frame.updates ?? []) {
        if (u.e) {
          console.log(`${u.sb} / ${u.sq}: ${u.e}`);
          continue;
        }
        console.log(`slot ${frame.u}  bid ${u.b}  ask ${u.a}`);
      }
    };

    ws.onerror = (error) => console.error("WebSocket error:", error);
    ws.onclose = () => console.log("WebSocket connection closed");
    ```
  </Accordion>

  <Accordion title="TypeScript Interface">
    ```typescript theme={null}
    interface QuoteUpdate {
      sb: string; // base mint
      sq: string; // quote mint
      b?: string; // bid, quote per base
      a?: string; // ask, quote per base
      B?: string; // bid size, quote-denominated
      A?: string; // ask size, quote-denominated
      e?: string; // per-pair error code
    }

    interface QuoteFrame {
      u: number; // slot
      ts: number; // unix seconds
      updates?: QuoteUpdate[];
      subscribe?: { sb: string; sq: string; auto: boolean }[];
      unsubscribe?: { sb: string; sq: string; auto: boolean }[];
    }
    ```
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Book Stream" href="book-stream" icon="layer-group">
    Stream 10 levels of order book depth
  </Card>

  <Card title="Market Data Streams" href="/spot/trading/market-data-streams" icon="signal-stream">
    How the streams work and when to use each
  </Card>

  <Card title="Websockets Overview" href="/resources/trading-api/websockets/overview" icon="plug">
    Connection details for Trading API streams
  </Card>

  <Card title="Stream Top-of-Book Quotes" href="/spot/recipes/stream-quotes" icon="code">
    Recipe: connect, subscribe, and read quotes
  </Card>
</CardGroup>
