Scanning NFT metadata


I’m attempting to collect NFT’s owner_hash and decode it to get the xch address.

I used Spacescan’s NFT API but seems like there is some issue in calling all of the NFTs. It seems to only call on partial of the NFTs in the collection.

I’m curious to know if there is another way around to pulling the complete data from an NFT collection.

Don’t think there is anything wrong with my code, just incase this is what im running;

from time import sleep
import json
import requests
import time

chamster_url = f''
r = requests.get(chamster_url)
chamster_json = r.json()
owner_hash = chamster_json['data']
chamster_count = (len(chamster_json['data']))
results = []

print(f'There are {chamster_count} NFTs in this API database.  Saving owner_hash values to json file in current directory')

for hash in owner_hash:
    owner_hashes = hash['owner_hash']
    owner_number = hash['meta_info']['name']
    print(owner_hashes, owner_number)
    data = {
        'name': owner_number, 

with open('hash_info.json', 'w') as f:
    json.dump(results, f, indent = 2)

Thanks -

I believe this is incorrect usage of the json module. Your API request should return a json string, then to work with it like you are in the rest of the script you need to convert it into a python dict with json.loads(r).

Thanks for posting this, actually made me realize some mistakes I was making with json returns from RPC calls :sweat_smile:

I thought its already a dictionary when I created result = [] and appended data to it?

data = {
        'name': owner_number,

It is not already a dict, when you get a request return, it returns a string of json data (one long line like {"key1":"value1","key2":"value2"} and then you can run json.loads to turn that string json object into a dictionary. Your example of declaring result as an empty list, and then appending data dictionary to it actually just makes it a list with a dictionary inside.