Fungibles now live Get started

How to calculate the value of your user’s NFT portfolio

Published on: 5/15/2023

How to calculate the value of your user’s NFT portfolio

Calculating the value of your users’ NFT portfolios just got a lot easier with SimpleHash’s API. SimpleHash offers an easy-to-use REST API that allows you to get the latest sale prices of individual NFTs across different marketplaces, as well as the floor price for any given NFT collection. In this tutorial, we’ll show you how to make requests to the SimpleHash API to calculate the value of user portfolios.

Getting started

Before we get started, you’ll need to sign up for a SimpleHash API key. You can do this by visiting the SimpleHash developer portal. This takes less than 2 minutes, and once you have your API key, you’re ready to start making requests.

If you’re building a wallet-related application, SimpleHash provides two main API endpoints that make this easy. These both assume you have access to the public wallet addresses of your users.

  • NFTs by Wallet(s) – use this endpoint if you want to get detailed NFT-level information on your user’s holdings. In the query params, you’ll need to provide the chains and wallet addresses you’d like to query – and you can further filter by contract or collection as needed.
  • Collections by Wallet(s) – use this endpoint if you want to get the summarized collection-level information on your user’s holdings In the query params, you’ll need to provide the chains and wallet addresses you’d like to query.

Regardless of the endpoint you use, you’ll still be able to calculate the real-time value of your users’ portfolios using the data provided in the responses.

If using NFTs by Wallet(s), in the responses, you’ll receive a set of NFT model objects representing the individual NFTs held by the queried-for addresses. These objects will contain both last_sale and collection sub-objects, the latter of which includes floor prices.

If using Collections by Wallet(s), you’ll receive a truncated version of the collection object that also includes floor prices.

What are last_sales and floor prices?

What is a last_sale? On the SimpleHash platform, we include full sale data for transactions across multiple chains and NFT marketplaces. The last_sale is the most recent sale for a given NFT. Historical sales can be obtained by querying the SimpleHash “Sales & Transfer by…” series of endpoints.

What is a floor price? An NFT collection floor price is the lowest price at which a collection of NFTs is expected to sell. It is based on the individual sale prices of each NFT in the collection and is used as a reference point for determining the overall value of the collection. The floor price is often calculated using market data and trends, as well as the rarity and demand for the specific NFTs in the collection. On the SimpleHash platform, we provide real-time data on floor prices across multiple different chains and NFT marketplaces.

Calculating the portfolio value

Depending on your use case, you now have different options for calculating the user’s portfolio value.

  • Floor price approach:
  • Iterate through each collection returned in the responses by using the Collections by Wallet(s) endpoint.
  • Multiply the distinct_nfts_owned field by the value field of the floor_prices for each collection.
  • Add up the results for each distinct currency.
  • This approach offers simplicity, but it may be imprecise because certain NFTs may sell for a different price than the overall collection floor price. Note that floor prices are updated in near real time on the SimpleHash platform.
  • Individual NFT last sale approach:
  • Use the NFTs by Wallet endpoint to iterate through each NFT.
  • For each NFT, multiply the unit_price value in the last_sale field by the quantity owned by the owner address in the owners field.
  • Add up the results.
  • This approach offers granularity, but the last sale of a given NFT may not necessarily be a good predictor of its future value, especially if the last sale occurred a long time ago. To make the approach more nuanced, you might only include last sale values if they occurred within a certain timeframe, which you can determine from the timestamp field on the last_sale body. Note that the quantity can be more than 1 for token standards like ERC1155 that allow copies.
  • Hybrid approach:
  • Another option is to mix and match the last sale and floor price approaches. For example, you could use the last_sale value if it occurred relatively recently for that NFT, and revert to the collection floor price if a significant amount of time has passed, or that particular NFT has never traded.

Most other SimpleHash API endpoints in addition to the two mentioned above also include the collection bodies, including the floor prices as needed for other use cases.

In addition, for real-time updates, developers can subscribe to the collection floor_price_update event using the SimpleHash webhook platform – which can be used to keep portfolio values as up to date as possible.

Conclusion

In this guide, we learned multiple approaches for calculating the portfolio of a user’s NFTs in the wallet(s), using the most recent sale data, and floor prices of NFT collections. Calculating the value of your users’ NFT portfolios is now as simple as querying a few endpoints. If you have any trouble following this guide, or with obtaining this kind of data, please feel free to reach out at support@simplehash.com, or to jump into our community telegram group.

About SimpleHash

SimpleHash provides access to all NFT data across 18 chains. We power NFTs for leading web3 players like Phantom and Rainbow. Using our API and webhooks, developers can get real-time metadata, media, transaction history, sale data, floor prices and ownership insights in just a few lines of code.SimpleHash is backed by leading industry players, such as Y Combinator, OpenSea Ventures, and Coinbase Ventures.

Getting NFT data is hard.

SimpleHash makes it easy.

Trusted by hundreds of web3 leaders:

Floor logo
Ledger logo
Brave logo
Rarible logo
Rainbow logo
Phantom logo
Manifold logo
Venly logo
Bitwave logo
Zerion logo
Nansen logo
Dappradar logo
Dust Labs logo
Bitski logo
Mask logo