For the complete documentation index, see llms.txt. This page is also available as Markdown.

getblock_subscribe - Solana Market Data

Open a Solana Market Data subscription over WebSocket. Complete guide on how to use getblock_subscribe in GetBlock Solana Market Data documentation.

getblock_subscribe opens a streaming subscription. It is the only method for starting a stream — the topic you pass determines which data model you receive. The service replies with a subscription ID, optionally sends an initial snapshot, and then pushes change sets until you unsubscribe or the socket closes.

Parameters

params is an array containing exactly one request object:

Parameter
Type
Required
Description

source

string

Yes

Data source. market for Solana Market Data, or priorityfee for priority-fee data.

topic

string

Yes

Data model to receive. One of trades, block, ohlcv, twap, vwap, volume, token.

params

object

Yes

Topic-specific parameters — the market pair, window, and delivery options. See the table below.

Market parameters

These go inside the nested params object.

Field
Type
Required
Description

base

string

No

Base58-encoded mint address of the base token.

quote

string

No

Base58-encoded mint address of the quote token.

mint

string

Yes for token

Base58-encoded token mint, used only by the token topic.

window

string

Yes for windowed topics

Aggregation period. Required by ohlcv, twap, vwap, and volume.

hydrate

integer

No

Size of the row set to maintain, 1–100. Sent as an initial snapshot, then held at this size.

throttle

string

No

Minimum interval between pushes. A positive integer followed by ms, s, m, or h.

Accepted window values for market topics:

1s, 10s, 30s, 1m, 5m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 24h

base and quote are optional. Omitting both subscribes you to every market, not to a default pair — a high-volume firehose spanning hundreds of pairs. Set both unless you genuinely want all markets.

limit, from, and to are query-only parameters and are not supported by the streaming API.

Request Example

Response Example

The first reply confirms the subscription and returns its ID:

Every message after that is a change-set notification. Note that the payload is nested under params.result, not result:

Response Parameters

Field
Type
Description

result

string

Hex-encoded subscription ID, returned once in reply to the subscribe request.

params.subscription

string

The subscription ID a notification belongs to. Use it to demultiplex the socket.

params.result.inserts

array

New rows, including the initial hydrate snapshot.

params.result.updates

array

Full replacement rows for previously emitted IDs whose values changed.

params.result.deletes

array

Rows to remove from local state by id. Carries the whole row, not just the ID.

A change-set property can be omitted when a notification contains no changes of that type. Process all three categories and ignore unknown row fields for forward compatibility.

Multiple subscriptions

One socket can carry several subscriptions at once. Send a getblock_subscribe request per stream, keep the returned IDs, and route incoming notifications on params.subscription:

Optimistic delivery and reconciliation

Solana produces an ordered sequence of slots, but recently observed data can still change before the network reaches finality. Waiting for finalization before publishing every market event would add latency and make the feed less useful for trading, monitoring, and automated execution.

Market Data therefore uses an optimistic streaming model. Rows are delivered as soon as they are available and can be corrected later through the same subscription.

The window parameter defines the aggregation period, not how long you wait for a first result. A subscription with "window": "10s" can receive a row before the ten-second window closes; as more trades enter that window, the service sends the latest version of the row in updates.

Error Handling

Code
Message
Cause

-32602

unsupported source "…": supported sources are "market" and "priorityfee"

source is not a recognized value.

-32602

unsupported topic: supported topics are trades, ohlcv, block, twap, vwap, volume, token

topic is not a recognized value.

-32602

window must be one of 1s, 10s, 30s, 1m, …

window is missing or not accepted on a windowed topic.

-32602

hydrate must be an integer from 1 to 100

hydrate is outside the accepted range.

-32602

throttle must be a positive integer followed by ms, s, m, or h

throttle is malformed.

-32602

base must be a base58-encoded 32-byte Solana public key

base or quote is not a valid mint address.

HTTP 401

authorization failed

API key missing, invalid, or the product is not activated on it.

Socket closes immediately with code 1006 and no reason. The server rejects unauthorized connections with HTTP 401 during the WebSocket handshake, but browser and Node WebSocket clients cannot read a handshake response body — they surface only 1006. Check that the apiKey query parameter is present and correct, and that Solana Market Data is activated on that key.

Last updated

Was this helpful?