Skip to main content
Many Cosmos SDK queries return paginated results. CosmJS query extensions accept an optional paginationKey parameter on paginated methods. Responses include a pagination field with a nextKey for fetching subsequent pages.

Manual Page-by-Page

How It Works

1

First call

Omit paginationKey (or pass undefined). CosmJS sends an empty PageRequest to the chain.
2

Read the cursor

The response includes pagination.nextKey — a Uint8Array cursor pointing to the next page.
3

Fetch next page

Pass the nextKey into the next call to fetch the following page.
4

Detect last page

When nextKey is undefined or empty, you’ve reached the last page.

Collecting All Results

A common pattern is to accumulate all pages into a single array:
StargateClient.getBalanceStaked uses this exact pattern internally to sum all delegations across pages.

Paginated Methods by Module

The IBC extension provides all* convenience methods (e.g., allChannels(), allConnections(), allDenomTraces()) that handle pagination internally and return all results in one call.

Next Steps

Querying Overview

All available query extensions.

Bank Queries

Example of paginated supply queries.