# Can't get events using the Access API

**URL:** <https://forum.flow.com/t/cant-get-events-using-the-access-api/5473>\
**Category:** 🛠 Developer Tools\
**Tags:** access\
**Created:** [December 11, 2023, 8:08pm UTC](https://forum.flow.com/t/cant-get-events-using-the-access-api/5473 "2023-12-11T20:08:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![agardez](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@agardez](https://forum.flow.com/u/agardez)\
**Post date:** [December 11, 2023, 8:08pm UTC](https://forum.flow.com/t/cant-get-events-using-the-access-api/5473/1 "2023-12-11T20:08:27Z")

</div>

Hello Flow community,

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).

First, I get a given block using the /blocks endpoint, e.g. [https://mainnet.onflow.org/v1/blocks?height=67524486&expand=execution\_result](https://mainnet.onflow.org/v1/blocks?height=67524486&expand=execution_result) which returns something like this:

```auto
...
        "execution_result": {
            "id": "8d0344f1a11f28bb38dca00e43dd7528d41eb927552f3c6e725e152471d5acf1",
            "block_id": "b00fea1c29eb7798d5f8afb6c17972291c0bb888cb445e52068bf6749516f45a",
            "events": [],
            "chunks": [
                {
                    "collection_index": "0",
                    "start_state": "c7z4Cqqa6O94TU3og7hmrrD4bp7nvU34QDAiPXF+bUs=",
                    "event_collection": "6c249640d50bc38d6600c67f4e5064f0fbd24d9d5b8b4f43c4f1e6f4138c60d0",

```

I notice “events” is always empty here… is that normal?

From here, I noticed “event\_collection”, which I suppose is to be fetched using the /collections API. However, this API always gives me a 404, for instance here using the value above, [https://mainnet.onflow.org/v1/collections/6c249640d50bc38d6600c67f4e5064f0fbd24d9d5b8b4f43c4f1e6f4138c60d0/](https://mainnet.onflow.org/v1/collections/6c249640d50bc38d6600c67f4e5064f0fbd24d9d5b8b4f43c4f1e6f4138c60d0/)

So my questions are:

1. if I want to find all the info of what happened in a given block, is this approach viable? Am I going in the right direction?
2. Am I doing something wrong here, to not ever get a proper response to the /collections endpoint?

Thank you in advance for your help!

---

<div class="post-metadata">

**Author:** ![petera](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/petera/32/1775_2.png) [@petera](https://forum.flow.com/u/petera)\
**Post date:** [December 11, 2023, 10:52pm UTC](https://forum.flow.com/t/cant-get-events-using-the-access-api/5473/2 "2023-12-11T22:52:28Z")

</div>

hi @agardez!

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]`

---

<div class="post-metadata">

**Author:** ![agardez](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@agardez](https://forum.flow.com/u/agardez)\
**Post date:** [December 12, 2023, 5:54pm UTC](https://forum.flow.com/t/cant-get-events-using-the-access-api/5473/3 "2023-12-12T17:54:49Z")

</div>

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.

Thanks again!

---

<div class="post-metadata">

**Author:** ![agardez](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@agardez](https://forum.flow.com/u/agardez)\
**Post date:** [December 15, 2023, 7:42pm UTC](https://forum.flow.com/t/cant-get-events-using-the-access-api/5473/4 "2023-12-15T19:42:50Z")

</div>

Hello @petera ,  
This worked well, thank you.

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?

Thank you
