
Python調用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 對數據進行排序將過濾掉不可出售的資產以及托管出售的資產。
要使用 OpenSea API 獲取捆綁包數據,您需要訪問捆綁包端點。每個捆綁包由一組打包在一起并出售的資產表示。打包過程不需要 gas。
bundles = pd.DataFrame(requests.get("https://api.opensea.io/api/v1/bundles?limit=10&offset=0").json()['bundles'])
bundles.head().T
要使用 OpenSea API 獲取單個資產,您需要使用asset
資產合約的地址和代幣 ID 調用端點。讓我們按如下方式獲取 cryptopunks 資產;
asset = requests.get("https://api.opensea.io/api/v1/asset/0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb/1/").json()
asset
如果你想要深入研究資產描述或資產收集等特定點,你可以這樣寫:
asset['description']
asset['collection']
要獲取 OpenSea API 的合約,您需要asset_contract
使用提供的資產合約地址作為請求參數來調用端點。為此,請查看以下代碼:
requests.get("https://api.opensea.io/api/v1/asset_contract/0x06012c8cf97bead5deae237070f9587f8e7a266d").json()
OpenSea events
API 端點將返回 OpenSea 可跟蹤的某些資產上正在發生的事件列表。其中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
端點發送請求。此 API 調用非常有用,因為您可以查看帳戶中有哪些項目以及有多少個項目。
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
端點。
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