Skip to main content

GetEventsForHeightRange Access API Method

Retrieves events emitted within the specified block range.

Updated on
Oct 4, 2023

GetEventsForHeightRange Access API Method

Parameters

Type
string
REQUIRED
The type of event
StartHeight
integer
REQUIRED
The starting block height of the range
EndHeight
integer
REQUIRED
The ending block height of the range

Returns

results
array
An array of event results, containing the following properties:
block_id
string
The ID of the block that contains the event
block_height
integer
The height of the block that contains the event
block_timestamp
object
The details of the block's timestamp, including the following properties:
seconds
integer
The seconds component of the timestamp
nanos
integer
The nanoseconds component of the timestamp
Request
1
package main
2
3
import (
4
"context"
5
"encoding/json"
6
"fmt"
7
"log"
8
9
"github.com/onflow/flow/protobuf/go/flow/access"
10
)
11
12
func main() {
13
14
// Requires authenticating before making the request. Refer to Intro Page on how Authentication can be done.
15
client, err := getAccessClientWithBasicAuth("ENDPOINT-NAME", "TOKEN_GOES_HERE")
16
ctx := context.Background()
17
if err != null {
18
log.Fatalf("err: %v", err)
19
}
20
21
// Get Events For HeightRange
22
eventType := "A.7cc345e1a0fc4283.JoyrideGameShim.FinalizeTransaction"
23
24
eventsResp, err := client.GetEventsForHeightRange(ctx, &access.GetEventsForHeightRangeRequest{Type: eventType, StartHeight: 54707711, EndHeight: 54707811})
25
if err != null {
26
log.Fatal("Get Events For HeightRange failed: ", err)
27
}
28
respJSON, err := json.Marshal(eventsResp)
29
if err != null {
30
log.Fatal("err: ", err)
31
}
32
fmt.Println("GetEventsForHeightRange response:", string(respJSON))
33
34
}
35
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free