---
title: "SDK WebSocket Usage | 0xArchive Docs"
description: "Use 0xArchive SDK WebSocket helpers for live subscriptions, replay, continuity handling, reconnects, and market-data streams."
canonical_url: "https://www.0xarchive.io/docs/sdks/websocket-usage/"
markdown_url: "https://www.0xarchive.io/docs/sdks/websocket-usage.md"
route: "/docs/sdks/websocket-usage"
robots: "index, follow"
generated_from: "prerendered_html"
---

# SDK WebSocket Usage

Live subscriptions and replay in the SDKs follow the same socket model as the WebSocket docs.

Modes Live and replay Clients Python, TypeScript, Rust

[Installation](https://www.0xarchive.io/docs/sdks/installation/)

[Reconstruction](https://www.0xarchive.io/docs/sdks/reconstruction/)

Official clients for the core API in Python, TypeScript, and Rust.

## WebSocket usage

The same client handles live subscriptions and replay.

```
import asyncio
from oxarchive import OxArchiveWs, WsOptions

async def main():
    ws = OxArchiveWs(WsOptions(api_key="0xa_your_api_key"))

    # Subscribe to real-time data
    ws.on_orderbook(lambda coin, data: print(f"{coin}: {data.mid_price}"))

    await ws.connect()
    ws.subscribe_orderbook("BTC")

    # Or replay historical data
    await ws.replay("orderbook", "BTC", start=1704067200000, speed=10)

asyncio.run(main())
```
