Skip to main content
Version: 0.9.1

Cursor Results

The SDK has a convenient way for fetching results longer than the default maximum of 500 entries. We use the more efficient cursor method here, but offset would work similar. An empty result means there is no more data available right now. As the chain grows you can obtain fresh data by using the most recent row_id like shown below

import (
"context"
"blockwatch.cc/tzpro-go/tzpro"
"blockwatch.cc/tzgo/tezos"
)

client := tzpro.DefaultClient
ctx := context.Background()
addr := tezos.MustParseAddress("tz1irJKkXS2DBWkU1NnmFQx1c1L7pbGg4yhk")
params := tzpro.NewOpParams()

for {
// fetch next batch from the explorer API
ops, err := client.GetAccountOps(ctx, addr, params)
// handle error if necessary

// stop when result is empty
if len(ops) == 0 {
break
}

// handle ops here

// prepare for next iteration
params = params.WithCursor(ops[len(ops)-1].RowId)
}