I tested with cursor now and it seems to work fine:
import requests
import time
ids = {}
def get_nft_owners(offset, cursor):
print("offset", offset)
url = 'https://deep-index.moralis.io/api/v2/nft/0x50f5474724e0ee42d9a4e711ccfb275809fd6d4a?chain=eth&format=decimal'
if cursor:
url = url + "&cursor=%s" % cursor
print("api_url", url)
headers = {
"Content-Type": "application/json",
"X-API-Key": "API_KEY"
}
statusResponse = requests.request("GET", url, headers=headers)
data = statusResponse.json()
try:
print("nr results", len(data['result']))
for x in data['result']:
ids[int(x['token_id'])] = 1
except:
print(repr(data))
print("exiting")
raise SystemExit
cursor = data['cursor']
print(data['page'], data['total'])
return cursor
cursor = None
for j in range(0, 211):
print("nr unique token_ids at offset", j*500, "=>", len(ids))
cursor = get_nft_owners(j*500, cursor)
print()
time.sleep(1.1)
print("nr unique token_ids", len(ids))