
Python調(diào)用Google Bard API 完整指南
import pandas as pd
assets = pd.DataFrame(requests.get("https://api.opensea.io/api/v1/assets?order_direction=desc&offset=0&limit=20").json()['assets'])
assets.head().T
請注意,按 listing_date 對數(shù)據(jù)進(jìn)行排序?qū)⑦^濾掉不可出售的資產(chǎn)以及托管出售的資產(chǎn)。
要使用 OpenSea API 獲取捆綁包數(shù)據(jù),您需要訪問捆綁包端點(diǎn)。每個捆綁包由一組打包在一起并出售的資產(chǎn)表示。打包過程不需要 gas。
bundles = pd.DataFrame(requests.get("https://api.opensea.io/api/v1/bundles?limit=10&offset=0").json()['bundles'])
bundles.head().T
要使用 OpenSea API 獲取單個資產(chǎn),您需要使用asset
資產(chǎn)合約的地址和代幣 ID 調(diào)用端點(diǎn)。讓我們按如下方式獲取 cryptopunks 資產(chǎn);
asset = requests.get("https://api.opensea.io/api/v1/asset/0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb/1/").json()
asset
如果你想要深入研究資產(chǎn)描述或資產(chǎn)收集等特定點(diǎn),你可以這樣寫:
asset['description']
asset['collection']
要獲取 OpenSea API 的合約,您需要asset_contract
使用提供的資產(chǎn)合約地址作為請求參數(shù)來調(diào)用端點(diǎn)。為此,請查看以下代碼:
requests.get("https://api.opensea.io/api/v1/asset_contract/0x06012c8cf97bead5deae237070f9587f8e7a266d").json()
OpenSea events
API 端點(diǎn)將返回 OpenSea 可跟蹤的某些資產(chǎn)上正在發(fā)生的事件列表。其中event_type
精確指定了獲取的事件類型。
events = pd.DataFrame(requests.get("https://api.opensea.io/api/v1/events?only_opensea=false&offset=0&limit=10").json()['asset_events'])
events.head().T
要使用 OpenSea API 獲取集合,用戶需要向collections
端點(diǎn)發(fā)送請求。此 API 調(diào)用非常有用,因?yàn)槟梢圆榭磶糁杏心男╉?xiàng)目以及有多少個項(xiàng)目。
collections = pd.DataFrame(requests.get("https://api.opensea.io/api/v1/collections?offset=0&limit=10").json()['collections'])
collections.head().T
要使用 OpenSea API 獲取訂單,您需要訪問 OpenSea 訂單簿orders
端點(diǎn)。
orders = pd.DataFrame(requests.get("https://api.opensea.io/wyvern/v1/orders?bundled=false&include_bundled=false&include_invalid=false&limit=10&offset=0&order_by=created_date&order_direction=desc",
headers = {"Accept":"application/json"}
).json()['orders']
)
orders.head().T