We must first locate what table has the data we need. The
nft.polygon_trades table has the information we want, including transactions, collections, and time.
The SQL query should look like this:
SELECT COUNT(DISTINCT tx_hash) AS number_of_transactions, COUNT(DISTINCT buyer) AS number_of_buyers, SUM(amount_usd) as volume, coalesce(collection, nft_contract_address) AS label FROM nft.polygon_trades WHERE data_creation_date >= CURRENT_DATE - INTERVAL '30' DAY GROUP BY 4 ORDER BY number_of_transactions DESC LIMIT 15
Unfortunately, not all collections have a collection name. We use the coalesce function to search first for the collection name, and if it does not exist, we can display the contract address.
We also grab the sales volume and the number of buyers. This gives us the ability to compare the number of sales with the number of buyers (signalling if NFTs have been traded between the same wallets many times).
Once we run the query, we can see the results in a table view. At the time of writing, the top NFT collection on Polygon, based on the most transactions in the past 30 days, is NFT1.
Next, we can create an API to surface this data wherever we want, including your own applications or dashboards.
And that’s it! Creating the API takes one click, and it’s ready! You can choose what you want to index and how often you want the API to refresh.
Updated 8 months ago