> For the complete documentation index, see [llms.txt](https://docs.outpoll.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.outpoll.com/api/futures-api/websockets/futures-market-data/best-quote.md).

# Best Quote

Real-time best bid and best ask for futures pairs.

Use this stream when you need only the top of the book — the best bid and best ask with their sizes — without maintaining a full order book.

### Endpoint

```
wss://futures-marketdata-service.outpoll.com/ws/book/best
```

### Authentication

No authentication required.

### Message Envelope

| Field | Type    | Description                              |
| ----- | ------- | ---------------------------------------- |
| `pi`  | string  | Pair ID, as a string (for example `"1"`) |
| `a`   | array   | Best ask `[price, size]`                 |
| `b`   | array   | Best bid `[price, size]`                 |
| `t`   | integer | Quote time, epoch ms                     |

### Message Types

| Type                        | Direction       | Description                                                                                    |
| --------------------------- | --------------- | ---------------------------------------------------------------------------------------------- |
| `subscribe` / `unsubscribe` | Client → Server | Start or stop pairs                                                                            |
| Quote                       | Server → Client | Current best bid and ask of one pair                                                           |
| Error                       | Server → Client | `{"er", "msg"}` — see [Errors](broken://pages/7b60c6363e2dcb27a5c7d2ef03222a2bd85342c5#errors) |
| `ping` / `pong`             | Both            | Plain-text keep-alive                                                                          |

### Subscribe

```json
{"act": "subscribe", "ps": [1, 2]}
```

Every pair:

```json
{"act": "subscribe", "all": true}
```

Server confirmation: there is no confirmation frame. When you subscribe by pair ID, the pair's current quote arrives immediately. With `all: true`, quotes arrive as each pair updates.

Updates are pushed whenever the pair's order book updates. Each frame is the complete top of book — replace the previous value.

### Quote Payload

```json
{
  "pi": "1",
  "a": [64250.5, 0.412],
  "b": [64250.4, 0.731],
  "t": 1790662754945
}
```

| Field | Type    | Description               |
| ----- | ------- | ------------------------- |
| `pi`  | string  | Pair ID                   |
| `a`   | array   | Best ask: `[price, size]` |
| `b`   | array   | Best bid: `[price, size]` |
| `t`   | integer | Quote time, epoch ms      |

### Python Example

{% code title="best\_quote.py" %}

```python
import asyncio
import json
from decimal import Decimal

import websockets

URL = "wss://futures-marketdata-service.outpoll.com/ws/book/best"


async def main():
    async with websockets.connect(URL) as ws:
        await ws.send(json.dumps({"act": "subscribe", "ps": [1, 2]}))
        async for raw in ws:
            if raw == "pong":
                continue
            msg = json.loads(raw, parse_float=Decimal)
            if "er" in msg:
                print("error:", msg)
                continue
            ask_price, ask_size = msg["a"]
            bid_price, bid_size = msg["b"]
            spread = ask_price - bid_price
            print(f"pair {msg['pi']}: bid {bid_price} / ask {ask_price}, spread {spread}")


asyncio.run(main())
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.outpoll.com/api/futures-api/websockets/futures-market-data/best-quote.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
