Skip to main content

Paginate results

Infura NFT endpoints that return a large number of results, return a maximum of 100 results per page. For methods that support it, you can pass in the cursor parameter returned by a previous call.

The following example displays the first 2 pages (200 results) of the Bored Ape Yacht Club NFTs.


The example uses the dotenv JavaScript package to load environment variables from a .env file into the process.env variables.

// Import the libraries and load the environment variables.
import { config as loadEnv } from "dotenv";
import { SDK, Auth, TEMPLATES, Metadata } from "@infura/sdk";


// Create Auth object
const auth = new Auth({
projectId: process.env.INFURA_API_KEY,
secretId: process.env.INFURA_API_KEY_SECRET,
privateKey: process.env.WALLET_PRIVATE_KEY,
chainId: 1,

// Instantiate SDK
const sdk = new SDK(auth);

// Get Nfts by collection
const nftsFirstPage = await sdk.api.getNFTsForCollection({
contractAddress: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
console.log("NFTs first page:", nftsFirstPage);

const nftsSecondPage = await sdk.api.getNFTsForCollection({
contractAddress: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
cursor: nftsFirstPage.cursor,
console.log("NFTs second page:", nftsSecondPage);