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

# BBO stream

> Receive finalized best bid and offer snapshots.

```text theme={null}
bbo@f[@<coalesceMs>]
```

This market-scoped snapshot stream publishes the current best bid and offer.
The duration is optional and defaults to `50` milliseconds. It does not use a
replay cursor.

## Subscribe

```json theme={null}
{
  "op": "sub",
  "id": 4,
  "t": "bbo@f@500",
  "m": "0x8121EE960066e4344A213F9aC7502395502aEe7a",
  "feedEpoch": 0
}
```

## Decoded event

The shape below is the inner `message` returned by `decodeExchangeWsEnvelope`
or `decodeExchangeWsMessage`. Every binary socket message also carries an outer
`id: bigint`, matching your subscription ID. Use it to route snapshots, replay,
and live updates. See [binary subscription envelopes](/api/exchange/websocket#binary-subscription-envelope).

```ts theme={null}
interface ExchangeWsBboLevel {
  price: bigint;
  totalBase: bigint;
}

interface ExchangeWsBboFrame {
  wireVersion: 1;
  feedEpoch: bigint;
  view: "finalized";
  kind: "bbo";
  marketAddress: string;
  marketSeq: bigint;
  globalSeq: bigint;
  stateHead: { blockNumber: bigint; blockId: string };
  bid: ExchangeWsBboLevel | null;
  ask: ExchangeWsBboLevel | null;
}
```

An empty side is `null`. `price` is a native pp integer and `totalBase` is a
native sp integer. Both decode as `bigint`.


## AsyncAPI

````yaml api/exchange/asyncapi.yaml bbo
id: bbo
title: Subscribe to BBO snapshots
description: Receive finalized best bid and offer snapshots.
servers:
  - id: mainnet
    protocol: wss
    host: gateway.mainnet.kuru.io
    bindings: []
    variables: []
  - id: testnet
    protocol: wss
    host: gateway.testnet.kuru.io
    bindings: []
    variables: []
address: /ws
parameters: []
bindings: []
operations:
  - &ref_1
    id: subscribeBbo
    title: Subscribe bbo
    type: receive
    messages:
      - &ref_2
        id: request
        contentType: application/json
        payload:
          - name: bbo@f subscription
            type: object
            properties:
              - name: op
                type: string
                enumValues:
                  - sub
                required: true
              - name: id
                type: integer
                description: >-
                  JSON integer restricted to JavaScript's exact safe-integer
                  range.
                required: true
              - name: t
                type: string
                required: true
              - name: m
                type: string
                description: Lowercase 20-byte market contract address.
                required: true
              - name: feedEpoch
                type: integer
                description: Feed namespace. Required when seq is supplied.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - op
            - id
            - t
            - m
          properties:
            op:
              type: string
              enum:
                - sub
              x-parser-schema-id: <anonymous-schema-44>
            id: &ref_0
              type: integer
              minimum: 0
              maximum: 9007199254740991
              description: >-
                JSON integer restricted to JavaScript's exact safe-integer
                range.
              x-parser-schema-id: ControlInteger
            t:
              type: string
              pattern: ^bbo@f(@[1-9][0-9]*)?$
              x-parser-schema-id: <anonymous-schema-45>
            m:
              type: string
              pattern: ^0x[0-9a-f]{40}$
              description: Lowercase 20-byte market contract address.
              x-parser-schema-id: MarketAddress
            feedEpoch:
              allOf:
                - *ref_0
              description: Feed namespace. Required when seq is supplied.
              x-parser-schema-id: FeedEpoch
          x-parser-schema-id: BboSubscription
        title: bbo@f subscription
        example: |-
          {
            "op": "sub",
            "id": 4,
            "t": "bbo@f@500",
            "m": "0x8121EE960066e4344A213F9aC7502395502aEe7a",
            "feedEpoch": 0
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: request
    bindings: []
    extensions:
      - id: x-parser-unique-object-id
        value: bbo
sendOperations:
  - *ref_1
receiveOperations: []
sendMessages:
  - *ref_2
receiveMessages: []
extensions:
  - id: x-parser-unique-object-id
    value: bbo
securitySchemes: []

````

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