Python SDK get_nft_owners returns 2 pages less when used with cursor pagination

Hi,

I’m trying to get NFT owners by contract using cursor pagination. When I set the limit parameter to 100 - as default - it returns 44 items which is correct. But when I set the limit to 10 - lower than the result count (44) - it returns 24 items. It returns total of 3 pages which must be 5 obviously.

Functions:

def get_nft_holders(api_key, address, limit, cursor):
    params = {
        "address": address,
        "chain": "eth",
        "format": "decimal",
        "limit": limit,
        "cursor": cursor,
        "normalizeMetadata": True,
    }

    result = evm_api.nft.get_nft_owners(
        api_key=api_key,
        params=params,
    )

    return result
api_key = os.environ['APIKEY']
cursor = ""

while True:
    result = get_nft_holders(api_key, args.contract, 10, cursor)
    cursor = result["cursor"]
    print(cursor)
    print(result["page"])

    if cursor is None:
        break

I’ve tried it in the API reference page. Also returns 3 pages total:

Here is the result for the last page:

{
  "total": null,
  "page": 3,
  "page_size": 10,
  "cursor": null,
  "result": [
   ....
  ]
}

The contract I am testing is:
https://etherscan.io/address/0x59932ba5b4393206325669be2de9de9d90c59e43

When I try with a contract that has a large number of tokens like the one below - has 1600 tokens - with a limit of 100 - as default - it also returns 1400 items which is weird:
https://etherscan.io/address/0x18aefe20ff1dd8e95f723567c886319598e9c8a8

we have a known issue with disable_total set to true, the value that is default now, it should work as expected if you set disable_total to false

Yes! Thats it! Thanks a lot!

1 Like

Hi, Devbhang. May I know how are you finding moralis services to far?