How can I get the last block or slot with all transactions in it with one Solana API request? The way I found: getSlot() -> getBlock(slotNumber). The problem with this method is that it is very slow. To get full information about a block you need to make 2 requests, it takes 1 or more seconds, and I need to process every new block in the network that comes out once every 0.4 sec. How can I get information about a new block with one request?

1 Answer 1


If you want to process every block as it comes in, the better option is to use the subscription API blockSubscribe https://docs.solana.com/api/websocket#blocksubscribe

Otherwise, rather than constantly calling getSlot first, you can get a whole range using getBlocks https://docs.solana.com/api/http#getblocks or getBlocksWithLimit https://docs.solana.com/api/http#getblockswithlimit in the beginning, and then keep incrementing the slot by 1 and calling getBlock as you were doing before. Some slots will be empty, and that's normal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.