import requests def get_nfts(wallet_address, end_index=1000): url = f"https://polygon-mainnet.g.alchemy.com/v2/{api_key}/getNFTs" params = { "owner": wallet_address, "withMetadata": "false" } token_ids = [] page_key = None while True: if page_key: params['pageKey'] = page_key response = requests.get(url, params=params) if response.status_code == 200: data = response.json() nfts = data.get('ownedNfts', []) token_ids.extend([int(nft['id']['tokenId'], 16) for nft in nfts]) page_key = data.get('pageKey') if not page_key: break else: print(f"Error fetching NFTs: {response.status_code}") break filtered_token_ids = [token_id for token_id in token_ids if token_id > 9] # 1자리 수 제거 # Return only up to end_index elements return filtered_token_ids[-end_index:] # 사용 예제 api_key = "4tRBr-iKmuEiV0wXmfHbrYPPCCd3cRDt" #wallet_address = "0x9526E51ee3D9bA02Ef674eB1E41FB24Dc2165380" #token_ids = get_nfts(wallet_address) #print("NFT Token IDs:", token_ids)