Request the data you need by POSTing to /stream
and you shall receive a stream of newline-separated JSON objects that package your data by block. For example
outputs
Here, we requested all records on instructions executed against the MoonCVV...Trg
program, with a bare minimum of fields. One such record was found for block 325000000. There were no records of such instructions being executed in block 325000001, but the block was included anyway to indicate the range boundary.
By using this general approach, you can
Solana data is updated in real time and includes unfinalized blocks, enabling latencies of 1-2 s. Just omit the toBlock
field in the request and you’ll get the latest data.
Real life protocols and infra introduce a couple of complications that you need to know about to actually build a client:
The endpoint may terminate the stream of blocks at any point. To resume the stream the client must update the fromBlock
and the optional parentBlockHash
fields of its request and send the request to the API again.
Note that that does mean that our example theoretically could have taken two requests instead of one.
If your request specifies a toBlock
you can tell that it’s done when you get either a block with this slot number or an empty HTTP 200 response.
If the range of your request is entirely above the range of available blocks you’ll get an HTTP 204 (No Content).
Ensuring data correctness when streaming unfinalized blocks is somewhat complicated. If you don’t want to deal with that complexity and don’t mind that the newest available data is up to several hours old, use the alternative /finalized-stream
endpoint; otherwise read on.
Some of the shared code for pipes and the Squid SDK will deal with unfinalized blocks for you under the hood.
For Solana use
Other SVM networks TBA.
/head
by some thousands of slots.Request the data you need by POSTing to /stream
and you shall receive a stream of newline-separated JSON objects that package your data by block. For example
outputs
Here, we requested all records on instructions executed against the MoonCVV...Trg
program, with a bare minimum of fields. One such record was found for block 325000000. There were no records of such instructions being executed in block 325000001, but the block was included anyway to indicate the range boundary.
By using this general approach, you can
Solana data is updated in real time and includes unfinalized blocks, enabling latencies of 1-2 s. Just omit the toBlock
field in the request and you’ll get the latest data.
Real life protocols and infra introduce a couple of complications that you need to know about to actually build a client:
The endpoint may terminate the stream of blocks at any point. To resume the stream the client must update the fromBlock
and the optional parentBlockHash
fields of its request and send the request to the API again.
Note that that does mean that our example theoretically could have taken two requests instead of one.
If your request specifies a toBlock
you can tell that it’s done when you get either a block with this slot number or an empty HTTP 200 response.
If the range of your request is entirely above the range of available blocks you’ll get an HTTP 204 (No Content).
Ensuring data correctness when streaming unfinalized blocks is somewhat complicated. If you don’t want to deal with that complexity and don’t mind that the newest available data is up to several hours old, use the alternative /finalized-stream
endpoint; otherwise read on.
Some of the shared code for pipes and the Squid SDK will deal with unfinalized blocks for you under the hood.
For Solana use
Other SVM networks TBA.
/head
by some thousands of slots.