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

# streamPrices

> Open a live WebSocket price stream from the Ostium Builder SDK.

```ts theme={null}
const stream = client.streamPrices([0, 1]);

stream.onSnapshot(ticks => {
  console.log(ticks);
});

stream.onTick(tick => {
  console.log(tick.pair, tick.mid);
});
```

You can update subscriptions dynamically:

```ts theme={null}
stream.subscribe([2]);
stream.unsubscribe([1]);
```

You can call `streamPrices(pairIds)` immediately after client creation. The SDK does not require a preloaded pair cache; if pair metadata is still loading, the stream connects and applies the pair filter once the metadata resolves. `subscribe()` and `unsubscribe()` calls made while the socket is still connecting are sent when the socket opens.

## Response schema

```ts theme={null}
interface Response {
  onSnapshot(handler: (ticks: PriceTick[]) => void): () => void;
  onTick(handler: (tick: PriceTick) => void): () => void;
  onOpen(handler: () => void): this;
  onError(handler: (event: Error) => void): this;
  onClose(handler: (code: number, reason: string) => void): this;
  subscribe(pairIds: Array<string | number>): this;
  unsubscribe(pairIds: Array<string | number>): this;
  close(): void;
  readonly readyState: number;
}

interface PairSchedule {
  id: number;
  alwaysOpen?: boolean;
  timezone?: string;
  openingHours?: string[];
}

interface PriceTick {
  pairId?: string;
  feedId: string;
  pair: string;
  from: string;
  to: string;
  bid: number;
  mid: number;
  ask: number;
  isMarketOpen: boolean;
  isDayTradingClosed: boolean;
  secondsToToggleIsDayTradingClosed: number;
  timestampSeconds: number;
  schedule?: PairSchedule;
}
```
