簡體   English   中英

尋找 Opensea NFT 的地板

[英]Find Floor Of Opensea NFT

有沒有辦法獲取 NFT 收藏主頁上顯示的底價?

在此處輸入圖像描述

在這里你看到底價是 5.75 但如果我使用 Opensea api 查詢合同:

url = "https://api.opensea.io/api/v1/asset/0x1cb1a5e65610aeff2551a50f76a87a7d3fb649c6/1/"

response = requests.request("GET", url)

print(response.text)

我得到一個樓層:

在此處輸入圖像描述

所以看起來 api 有點偏離。 只是好奇這里是否有人知道獲得更准確底價的更好方法?

底價適用於收藏品(合同)。 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM