Get all nft owners through contract address

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


it prints {‘version’: ‘0.0.53’}

import requests
import time

def get_nft_owners(offset, cursor):
print(“offset”, offset)
url = ‘
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)
    print("nr results", len(data['result']))
    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)

what is the error that you get on the second python script? the one that makes http requests directly without the sdk

the code that you used is from this example?

The code is executing properly.But when I clicked on the api this is appearing.
{“message”:“API KEY missing from x-api-key header”}.I have also attached a screenshot.

Screenshot (33)|690x387

That error is expected fi you open that url in the browser, it needs the api key set in the http header in order to work.

Yes then where to exactly place that api key in the http header. I am directly opening it in the google chrome browser.

Now this is one of the url’s

Exactly where to place the api key?

In the http header, not in the url, you will have to use postman or other tool that can add a field in the http header

Ok I got this kind of a response by using postman which I am attaching in the attachments.Is this correct?I also wanted to know in one response I will be getting 500 records right.

That looks ok, that response, the number of results in a page is 100, you have to use pagination (that cursor parameter) to get the other results if there are more than 100 results

Well its giving me the results but it can’t be automated.I got a couple of api’s and each api I have to compy and paste it in postman.From one api I will get 100 records only.So its does become a manual process in the end.

you can write a script to do that automation

But how will I be able to that. If you have such a script please do help me.

There is a python example in documentation for how to use pagination.