Overview
Struct’s websocket API streams onchain DEX data without polling REST. Connect once, subscribe to any number of rooms, and receive live updates for trades, balances, trending, pulse, PnL, Uniswap, and more. Almost every room requireschain or chain_id on the subscribe message.
Pass
chain or chain_id on requests that need a chain. Rooms and endpoints with multi-chain support, including Pulse and Trending, also accept chains and chain_ids; those selectors are combined. Follow the individual endpoint or room reference. Polygon is not a supported onchain chain.
Endpoint
Authentication
Authenticate by appending your API key as a query parameter:token parameter. See Authentication for both flows.
Field names
Every onchain REST and WebSocket payload is available with long (full) or short (abbreviated) field names. The example panel on the right has Response (Long) and Response (Short) so you can compare the same payload in both modes.short and long are accepted across these surfaces. The HTTP
/token/market/candlestick endpoint also accepts fields=array (or
x-field-names: array), returning [time, open, high, low, close, volume] rows
with millisecond timestamps and retained null slots. Other HTTP endpoints and
WebSocket connections reject array. See token candlesticks. Successful HTTP responses echo the chosen mode in the x-field-names response header. On WebSocket the mode is fixed per connection and every room honours it: each room’s update payloads arrive in the connection’s mode, whichever rooms you join.
Use long when you want readable names such as market_cap_usd and token_address. Use short when you want smaller messages (mc, ta) — typical for high-frequency WebSocket clients.
The lock endpoints (/token/locks, /token/pool-locks, /token/owner-locks and /token/lock-events) shorten their keys like every other endpoint: data is the list of lock entries or events, each with short keys. On token and pool rows, lp_security is ls and supply_locks is sl. On token holder rows, a locker’s locks breakdown is lks. See LP and token locks for the lock key table.
Envelope keys stay the same in both modes (success, data, type, room_id, interval_ms, WebSocket frame keys beside data such as chain, chain_id, token_address and timeframe, and Pulse/Trending frame keys such as columns and rows). Subscribe responses and errors also keep long keys. Only the payload fields change.
Compression
High-throughput sockets can opt into zstd compression, negotiated once at the WebSocket upgrade with theX-Ws-Compression: zstd header or the ?compression=zstd query fallback. When enabled, room messages arrive as binary frames of zstd-compressed JSON. See Compression for decode examples and client support.
Your first connection
1
Create an account
Sign up at struct.to/dashboard and create an organisation.
2
Generate an API key
Open the API Keys page in your dashboard and create a new key. Copy the value somewhere safe; you won’t be able to view it again. See Authentication for key types, JWT public keys, and rotation.
3
Open a connection
Connect, join the Trades room, and subscribe to Solana trades for one token.
4
Receive events
Messages arrive as JSON with a
type field (the event name) and a payload. See the individual room pages for the events each room emits.Connection lifecycle
A typical session follows the same sequence for every room:Message protocol
All messages sent and received are JSON. Client messages have atype and payload:
Joining and subscribing
Subscribing to a room is a two-step flow:- Join the room with
join_room. - Wait for
room_joined. - Configure the subscription by sending a
room_messagewithaction: "subscribe", a chain selector, and any filters. Thetradesroom takes its chains insidetargets, so one connection can span chains.
subscribe message. The new filters replace the previous ones. Filter with subscribe fields instead of dropping messages locally — subscribe filters are free; dropping locally still bills you.
For Pulse and Trending, subscriptions are named views. Reusing a name replaces that view; other names remain active. Their first frame acknowledges the subscription. Apply frames with a consecutive sequence check.
hyped, lighthouse, and market_movement support multiple chains on one connection. Join the room, then subscribe with chain_ids: [-1, 4663] or chains: ["solana", "robinhood"]. Send another subscribe to replace your selected chains without reconnecting. Unavailable chains do not block updates from the others. Hyped and Lighthouse updates contain a chain-keyed snapshot; merge the included chain and retain the others. Market Movement updates replace the complete selected-chain response and report missing chains.
chain_status is the exception: join the room and the snapshot arrives without a subscribe message. native_prices takes currencies instead of a chain selector.
Unsubscribing
To stop receiving messages from a room, sendunsubscribe_all (or unsubscribe on rooms that support it) followed by leave_room:
Keepalive
Send a ping every 30 seconds to keep the connection alive:{ "type": "pong" } follows.
Firehose subscriptions
Most rooms acceptsubscribe_all: true on the subscribe message to receive every update on that stream instead of a targeted subset:
Available rooms
Every room emits its own event type with a typed filter and payload. Click a room for the full schema.Reconnection
Subscriptions last only for this connection. If the socket drops, reconnect and subscribe again. Space retries with exponential backoff and jitter.room_joined before replaying its views and replace room state with the initial reset.
For the full close-code reference, see Errors.
Connection limits
Each plan has a cap on concurrent connections across your organisation. A single connection can subscribe to many rooms, so you rarely need more than a handful of sockets in practice.
See Rate Limits for filter limits and the full per-key throughput matrix.
Next steps
- Browse the Rooms section for every available stream and its filters.
- Read Best Practices for resilience patterns.