# WebSockets

One socket, every chain. Stream live trades, order books, candlesticks, and positions across EVM and SVM behind a single typed schema, with JWT auth, auto-reconnect, and per-user rate limits.

## Live onchain data, streamed across every chain

- **One socket, every chain**: Trades, order books, candlesticks, and positions across EVM and SVM, all through typed data rooms on a single socket. Subscribe once and let data stream for as long as your connection stays open. Unified rooms span Trades, Order book, Candlesticks, Positions, and more.
- **Typed, resilient client**: Per-room typed filters and payloads. Auto-reconnect with subscription replay, JWT refresh, and lifecycle events built into the TypeScript SDK.
- **Millisecond latency**: Messages push the moment events land onchain. No polling loops, no cache windows, no waiting between updates.

## Every onchain stream, one socket away

Typed data rooms for trades, discovery, prices, and positions. Filtered, enriched, and pushed as they change across every chain.

- **Trade streams**: Live trade ticks by market, wallet, or globally as fills land onchain. Filter by chain, trader, or trade type.
- **Discovery & pulse streams**: A live pulse of new and trending tokens as they surface. Filter by chain, volume, momentum, age, and the dozens of dimensions leading terminals rely on.
- **Holder & account updates**: Token balance changes streamed per holder as transfers land onchain. Track any trader address, watch positions grow, and see new holders enter in real time.
- **Positions & PnL streams**: Per-wallet position size, cost basis, and realized PnL pushed as trades settle onchain, scoped to any chain.

Explore the full API reference: https://docs.struct.to

## One socket, everything you build on top

From consumer trading apps to autonomous agents, the same rooms power it all.

- **Trading Apps**: Build consumer trading apps with real-time discovery feeds, live prices, and token metrics, all from a single feed. Discovery feeds, live prices, token metrics.
- **Wallets & Portfolio**: Track any wallet on any chain, surface holdings and PnL, and power portfolio dashboards from real-time onchain balances. Holdings and PnL, any wallet on any chain, live balances.
- **AI Agents**: Give agents the context to research, monitor, and trade across tokens, markets, and wallets, wherever they trade. Research and monitoring, cross-market context, live trade data.

## Everything the platform gives you

The infrastructure behind production trading terminals, exposed as a streaming API across every chain.

- **JWT auth for end users**: Connect users directly from the browser with JWTs from Clerk, Auth0, or your own IdP. Secret keys stay server-side.
- **One socket per user**: Each connection gets its own subscriptions, typed filters, and per-user rate limits, so one socket per logged-in user just works.
- **Pay per message**: Credits are billed per message delivered, not per connection. Filters mean you pay only for the data you consume.
- **Unified multi-chain rooms**: The same rooms and payload types span EVM and SVM behind one schema. Learn the streams once and subscribe on any chain.
- **Benchmark-leading latency**: Messages arrive the moment events land onchain. Auto-reconnect with subscription replay keeps state consistent.
- **99.99% uptime**: Production-grade reliability, monitored around the clock so your socket never waits on ours.

## Frequently asked questions

### How do I get started with WebSockets?

Create a free account, generate an API key from your dashboard, and connect to the websocket endpoint. The documentation covers the handshake, room subscriptions, and payload shapes. The TypeScript SDK ships a typed client with auto-reconnect and subscription replay so you can subscribe to a room in a few lines.

### Can I connect end users directly from the browser?

Yes. Users connect with JWTs from any auth provider like Clerk, Auth0, or your own IdP. Ship a public key to the browser and keep your secret key server-side, so each logged-in user gets their own socket without exposing credentials.

### What do the streams cover?

The self-serve socket is Polymarket: trades, order books, candlesticks, and positions. Need other chains or protocols? That is an engagement. We stand up the rooms with your team: https://www.struct.to/apps

### What streams are available?

Typed data rooms cover trade streams, order book snapshots and deltas, price and candlestick ticks, positions and PnL updates, live market and event feeds, aggregated metrics, and wallet balances. A dedicated alerts socket adds pre-computed triggers for whale trades, volume spikes, price moves, and metric thresholds, all across every chain.

### How fresh is the data?

Data is pushed the moment it lands onchain or crosses a threshold, with benchmark-leading latency in production. There are no polling loops, cache windows, or reconnect bookkeeping. Your socket stays open and messages arrive as events happen.

### How do subscriptions and filters work?

Each room accepts typed filters so you subscribe to exactly the slice you need, by chain, market, token, wallet, or type. One socket per user holds many subscriptions at once, each with its own filters and per-user rate limits.

### What happens when a connection drops?

The TypeScript client reconnects automatically and replays your active subscriptions, refreshes JWTs, and emits lifecycle events so state stays consistent. You never have to rebuild subscription state by hand after a reconnect.

### How is WebSocket usage billed?

Credits are billed per message delivered, not per connection, with rates that vary by room. Quiet rooms cost nothing beyond a 1-credit hold when you open the socket, and filters let you pay only for the data you actually consume. See the pricing page for plan details.

### How many concurrent sockets can I open?

Plan caps scale from 1 to unlimited concurrent sockets, so one socket per logged-in user just works. Each connection gets its own subscriptions, filters, and per-user rate limits.

### Where can I find the full WebSocket reference?

The complete room reference, subscription parameters, and payload schemas live in the API reference. It documents every room, filter, and alert trigger across all supported chains.

## Learn more

- [REST API](https://www.struct.to/rest-api)
- [Webhooks](https://www.struct.to/webhooks)
- [Pricing](https://www.struct.to/pricing)
- [Documentation](https://docs.struct.to)
- [API reference](https://docs.struct.to/api-reference)
- [TypeScript SDK](https://docs.struct.to/sdk/getting-started)
