Subscription
Open one WebSocket, subscribe to any method, and receive a snapshot followed by live inserts, updates, and deletes. Tune what each subscription delivers with hydrate and throttle, and let the SDK recover dropped sockets for you.
Endpoint
Connect to the subscription endpoint and pass your token as a query parameter (WebSocket handshakes cannot carry headers). They take the same method names and params as a query.
wss://sub.raptor.trade?token=$RAPTOR_TOKENThe SDK handles the framing below for you; the raw frames are here for other languages.
Lifecycle
connect → subscribe → hydrate → live changes → unsubscribe
1. Subscribe. Send a request naming the method, your filter, and the streaming options. Client requests may be a single object or a batch array.
{
"jsonrpc": "2.0",
"id": 1,
"method": "solana::market::trades",
"params": {
"base": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
"hydrate": 50,
"throttle": "1s"
}
}2. Acknowledgement. The server replies with an array carrying the assigned subscription id. Use it to correlate later pushes and to unsubscribe.
[
{ "jsonrpc": "2.0", "id": 1, "result": { "subscription": 42 } }
]3. Hydration, then live changes. The first notification arrives right after the ack with up to hydrate recent data in inserts; every subsequent change uses the same id-less envelope. Empty buckets are always present.
[
{
"jsonrpc": "2.0",
"method": "solana::market::trades",
"result": {
"subscription": 42,
"inserts": [
{
"id": 1024,
"signature": "5h2k...g8Qa",
"signer": "7Np4...kRf2",
"slot": "37",
"timestamp": "2026-06-01T02:16:22.000000000Z",
"base": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
"quote": "So11111111111111111111111111111111111111112",
"base_amount": "238809604418900",
"quote_amount": "238809604418900",
"base_decimals": "9",
"quote_decimals": "9",
"base_volume": "48210.7531",
"quote_volume": "48210.7531",
"price": "0.00001923",
"is_buy": true
}
],
"updates": [],
"deletes": []
}
}
]4. Unsubscribe. Send the unsubscribe control method with the subscription id in a single-element array.
{ "jsonrpc": "2.0", "id": 2, "method": "unsubscribe", "params": [42] }[
{ "jsonrpc": "2.0", "id": 2, "result": true }
]Reading notifications
A push is a JSON-RPC notification - it has a method but no id - and its result holds the subscription id plus three buckets of full data. Apply inserts as new data, reconcile updates and deletes against data you hold by id. Under throttle, several changes are coalesced into one frame, so each bucket may hold multiple data points.
Throttle & hydrate
Two optional parameters shape what a subscription delivers and how often.
hydratethrottlehydrate
On subscribe - and again on every reconnect - the server replays up to hydrate most-recent data as the first notification's inserts, so you start with state rather than an empty view. Set it to 1 if you only want changes from now on. Values above 100 are clamped to 100.
throttle
The server coalesces changes within each throttle interval into a single notification, so a busy market never floods your socket. A duration is an integer plus a unit: 500ms, 2s, 15m. Because changes are batched, inserts, updates, and deletes can each carry several data points in one frame.
Automatic reconnect
If the socket drops, the SDK reconnects with exponential backoff starting at reconnect_delay_ms (default 1000ms) and doubling each attempt. By default it retries indefinitely; cap it with max_reconnect_attempts.
Resubscribe on reopen
After a genuine reconnect the client re-establishes every active subscription for you. Each gets a new server-side subscription id and a fresh hydration snapshot, so your callbacks resync with no extra work. Match data by id and treat a new snapshot as a reset of that stream.
Request timeouts
Set timeout_ms to reject a query or subscribe the server does not answer in time. Left unset, requests wait indefinitely.
Error frames
A bad subscribe - an invalid base or an unknown window, say - comes back as a JSON-RPC error response, which the SDK raises as an RpcError. See Errors for the codes.
Raw WebSocket clients
token query parameter again. Subscription ids from before the drop are no longer valid.