Skip to main content

Install

Building the client

Minimal:
Note that .build() is async - it establishes the WebSocket connection before returning. If the connection fails, you get the error immediately.

Builder methods

.url(url) - Primary WebSocket endpoint. Falls back to ORBITFLARE_WS_URL env var.
.urls(&[...]) - Primary + fallbacks in one call.
.fallback_url(url) / .fallback_urls(&[...]) - Add failover endpoints. On reconnect, the SDK rotates through them.
.api_key(key) - License key. Falls back to ORBITFLARE_LICENSE_KEY env var.
.retry(policy) - Reconnection backoff. Default: 100ms initial, 30s max, 2x multiplier, infinite attempts.
.ping_interval_secs(n) - How often the SDK sends WebSocket Ping frames. Default: 10.
.max_missed_pongs(n) - Pings without a response before killing the connection. Default: 3.

Available subscriptions

slot_subscribe()

Fires every time a slot is processed, confirmed, or finalized.
Each event is a JSON value with slot, parent, and root fields:

account_subscribe(address, commitment)

Fires when the specified account’s data changes.
Returns base64-encoded account data with lamports, owner, and executable flag.

logs_subscribe(mentions, commitment)

Fires for transactions that mention the given addresses. Pass an empty slice for all transactions.
All logs:

signature_subscribe(signature, commitment)

Fires once when a transaction reaches the given commitment level. Useful for confirming a transaction you just sent.

Reading events

All subscriptions return a WsSubscription. Call .next() to get the next event:
.next() returns Option<serde_json::Value>. None means the subscription was closed.

Unsubscribing

This sends an unsubscribe message to the server. If you drop a subscription without calling this, the SDK detects the orphan and sends the unsubscribe automatically.

Multiple subscriptions

All subscriptions run on a single WebSocket connection. The SDK routes notifications to the right subscription internally.
You can add new subscriptions at any time while existing ones are running.

Reconnection

If the connection drops, the background task reconnects with exponential backoff and re-subscribes everything automatically. Your .next() calls just keep working - events resume once the connection is back.

Full example

A monitoring script that subscribes to slot updates and account changes for USDC, printing a live feed.