I want to figure out how to fetch all events and transactions for a given block height.
I am trying to do it using the HTTP access API (I’m open to another way too).
the execution_result result field is actually some metadata about the results from executing the block. As you discovered, it doesn’t contain the data, and the names can be a little confusing. events is a list of “service events” produced during the block. These are for epoch transitions and other protocol level events. event_collection contains the hash of all events emitted during block execution.
The data you’re looking for is available using the gRPC/gRPC-Web endpoints GetTransactionsByBlockID and GetTransactionResultsByBlockID. These will return all transaction payloads and all transaction results (including events) respectively for the entire block.
To query using the REST api, you’ll need to something like:
Query the block, expanding the payload /v1/blocks?height=sealed&expand=payload
For each collection in the guarantee
query to get the tx bodies /v1/collections/[collection_id]?expand=transactions
query to get the tx result /v1/transaction_results/[transaction_id]
Hi @petera ,
Thanks for your response. I confirm I see the data I’m interested in now with the endpoints you mention.
I want to point out however that the documentation does not mention these endpoints anywhere - they only appear in the protobuf definition on GitHub (I’m glad they exist though! )
Also, the Python client for the access API is missing them, which is probably related to the above.
I’m working on indexing historical data for all events across the Flow blockchain. This is so that we can for instance later aggregate the events to compute balances for accounts.
From my understanding there are different endpoints for ranges of block heights, due to the sporks.
I could go ahead and use these different endpoints based on the block height I’m trying to fetch. However I see that there does not seem to be endpoints for before Candidate 4, which starts at block height 1065711.
Is there any way to access the blocks prior to this?
Alternatively, is there some other way to get historical data from the blockchain, such as a cloud bucket of block data exports or database to query?
Lastly, is the state from before mainnet 1 preserved, meaning are there accounts with activity before that, contracts deployed which would still be active?