Hello I have used this python code for getting all the nft owners.I got a response in the form of a couple of apiās but that apiās was giving this error
{āmessageā:āAPI KEY missing from x-api-key headerā}
Here is my python code:
import requests
import pandas as pd
import time
from tqdm import tqdm
pd.set_option(ādisplay.max_colwidthā, None)
import moralis
print(moralis.utils.web3_api_version(api_key=ā6vOnQdQcX1bobkZdmXaOmpHqShIJBxIJB12clWUu9TLX5XXWXtz1O4uiaxkuIsLfā))
it prints {āversionā: ā0.0.53ā}
import requests
import time
def get_nft_owners(offset, cursor):
print(āoffsetā, offset)
url = āhttps://deep-index.moralis.io/api/v2/nft/0x63e2938F85AC8C21F8099458A73A19fe4a33Ce00/owners?chain=polygon&format=decimalā
if cursor:
url = url + ā&cursor=%sā % cursor
print("api_url", url)
headers = {
"Content-Type": "application/json",
"X-API-Key": "6vonqdqcx1bobkzdmxaomphqshijbxijb12clwuu9tlx5xxwxtz1o4uiaxkuislf"
}
statusResponse = requests.request("GET", url, headers=headers)
data = statusResponse.json()
print("HTTP headers:", statusResponse.headers)
try:
print("nr results", len(data['result']))
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, 10):
cursor = get_nft_owners(j*5000, cursor)
print()
time.sleep(1.1)