import json
import time
import requests
def account_nfts(account_address, api_key):
# 初始API接口URL(包含next参数)
url = f"https://api.opensea.io/v2/chain/ethereum/account/{account_address}/nfts?limit=50"
# 总的nft数量
total_count = 0
headers = {
"accept": "application/json",
"X-API-KEY": api_key
}
while url:
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
# 提取NFT列表或其他您需要的数据
nfts = data.get("nfts", [])
current_page_count = len(nfts)
total_count += current_page_count
for nft in nfts:
print(f"NFT名称: {nft['name']}")
print(f"NFT合同地址: {nft['contract']}")
print(f"NFT图像URL: {nft['image_url']}")
# 获取下一页的游标,如果没有下一页,cursor将为None
next_cursor = data.get("next")
# 更新URL以获取下一页
if next_cursor
通过OpenSea API获取某一账户的NFT数据
于 2023-09-25 20:42:20 首次发布

最低0.47元/天 解锁文章
1681

被折叠的 条评论
为什么被折叠?



