Skip to main content
Paxos APIs use cursor-based pagination. The SDK provides auto-pagination iterators that handle page fetching automatically, so you can iterate through results without managing cursors.

How Paxos Pagination Works

  • List endpoints return a page of results plus a next_page_cursor
  • Pass the cursor to the next request to fetch the following page
  • When next_page_cursor is absent, you’ve reached the last page
  • The limit parameter controls the number of items per page
The SDK’s iterators fetch pages transparently. Iterate through results as if they were a single collection:
iter := client.Transfers.ListTransfers(ctx, &paxos.ListTransfersRequest{
    ProfileID: "profile_123",
    Limit:     50,
})

for iter.Next() {
    transfer := iter.Current()
    fmt.Printf("Transfer: %s%s %s\n", transfer.ID, transfer.Amount, transfer.Asset)
}
if err := iter.Err(); err != nil {
    log.Fatal(err)
}
The iterator fetches pages of 50 items at a time behind the scenes. When one page is exhausted, it automatically fetches the next one.

Manual Pagination

If you need direct control over page cursors (for example, to store a cursor and resume later), use the page-level methods:
var cursor string

for {
    resp, err := client.Transfers.ListTransfersPage(ctx, &paxos.ListTransfersRequest{
        ProfileID:  "profile_123",
        Limit:      50,
        PageCursor: cursor,
    })
    if err != nil {
        log.Fatal(err)
    }

    for _, transfer := range resp.Items {
        fmt.Printf("Transfer: %s\n", transfer.ID)
    }

    if resp.NextPageCursor == "" {
        break
    }
    cursor = resp.NextPageCursor
}

Performance Tips

  • Set an appropriate page size — Larger pages mean fewer network round-trips but more memory per page. Start with 50–100.
  • Break early — If you’re searching for a specific item, stop iterating once you find it.
  • Process pages in parallel — If ordering doesn’t matter, fetch the next page while processing the current one.

Error Handling During Pagination

If a network error or API error occurs mid-iteration, the iterator surfaces it:
for iter.Next() {
    // process items
}
if err := iter.Err(); err != nil {
    // handle error — you can resume from the last successfully processed item
    log.Printf("pagination failed: %v", err)
}