getWalletNFTs API returning wrong cursor data

Issue:
We are using the NFT getWalletNFTs API, but the cursor is not working correctly if the user has an nft higher than 100. We are using the version of “moralis”: “^2.14.1”.

Cursor JWT Response

{
  "customParams": {
    "tokenAddress": [
      "0x31385d3520bced94f77aae104b406994d8f2168c"
    ],
    "walletAddress": "0xc3b5284b2c0cfa1871a6ac63b6d6ee43c08bdc79"
  },
  "keys": [
    "1668293727.026"
  ],
  "where": {
    "token_address": [
      "0x31385d3520bced94f77aae104b406994d8f2168c"
    ],
    "owner_of": "0xc3b5284b2c0cfa1871a6ac63b6d6ee43c08bdc79"
  },
  "limit": 100,
  "offset": 0,
  "order": [],
  "disable_total": false,
  "total": 467,
  "page": 1,
  "tailOffset": 1,
  "iat": 1676147885
}

Code:

I tried with disablTotal false and it still not working properly. @cryptokid

I tried it now to iterate over the 5 pages and it worked without issues, you could try it few times if you get issues

you can test it directly in the docs interface too:

I’ve been trying for 2 or 3 hours with so many versions including Moralis-v1 and none of them works properly.In v1 version it always only iterated 2 pages if there are five pages.

I used this python script that calls the API directly:

import requests
import json
import time


def get_nfts(offset, cursor):
    url = 'https://deep-index.moralis.io/api/v2/0xc3b5284b2c0cfa1871a6ac63b6d6ee43c08bdc79/nft?chain=eth&format=decimal&disable_total=false&token_addresses%5B0%5D=0x31385d3520bced94f77aae104b406994d8f2168c'
    if cursor:
        url = url + "&cursor=%s" % cursor

    headers = {
        "Content-Type": "application/json",
        "X-API-Key": "API_KEY_HERE",
    }
    statusResponse = requests.request("GET", url, headers=headers)
    data = statusResponse.json()
    print(len(data['result']))
    print(data['total'])
    print(json.dumps(data, indent=4))
    cursor = data['cursor']
    return cursor


cursor = None
for j in range(10):
    print(j)
    cursor = get_nfts(j*100, cursor)
    if not cursor:
        break
    time.sleep(1.1)