[英]Find Floor Of Opensea NFT
底價適用於收藏品(合同)。 Opensea api 確實有一個集合端點,但它不能按所有者地址以外的任何內容進行過濾。 所以你必須知道某人的地址,我猜為什么擁有一個令牌,這似乎很弱智。
您還可以從資產端點獲取令牌的所有者,該端點可以按合同地址和令牌 ID 進行過濾。
我不知道為什么會這樣,但是...
https://api.opensea.io/collection/${slug}
slug
= 集合 slug(URL 中的名稱)。
作為參考,我在一些隨機的其他圖書館的文檔中找到了這個......但它似乎有效
在文檔中,它顯示了 API 的工作原理
這將返回所有統計信息。 因此,將集合的名稱更改為您想要的名稱,僅此而已。
我設法通過從我在 OpenSea 上的集合中獲取不同的數據並將它們顯示在我的網站上來使其工作。
應用程序.js:
function fetchData() {
// Using the OpenSea API's direct URL of the .json file from the collection
// Change the "OpenSeaCollectionNameSlug" in the URL to your collection's slug
fetch('https://api.opensea.io/api/v1/collection/OpenSeaCollectionNameSlug/stats?format=json')
.then(response => {
// If the data doesn't load properly from the URL, show a custom error message on the HTML file
if (!response.ok) {
throw Error('X');
}
return response.json();
})
.then(data => {
// Creating one or more const to put data inside
const floorprice = data.stats.floor_price
const owners = data.stats.num_owners
// Using id inside different span to add the content on the HTML file
// Using toFixed and toPrecision to round the output
document.querySelector('#floorprice').innerHTML = (floorprice).toFixed(3);
document.querySelector('#owners').innerHTML = Math.round(owners).toPrecision(2) / 1000;
// Keeping this console.log to see which other data stats can be fetched
console.log(data.stats);
});
}
fetchData();
索引.html:
<div>
<h1>OWNERS</h1>
<h3><span id="owners"></span></h3>
</div>
<div>
<h1>FLOOR PRICE</h1>
<h3><span id="floorprice"></span> Ξ</h3>
</div>
如果有人還在尋找,OpenSea 似乎添加了一個新端點,可以更准確地跟蹤底價:
https://docs.opensea.io/reference/retrieving-collection-stats
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.