2

I am working on Cardano NFT tool kit, which basically shows the NFT's owned by a user. The tool kit shows the various information about NFT stored in wallet like (Buy Price, Sold Price, Rarity, Holding period, Floor price) apart from this some other data like (Policy Id, FingerPrint, Collection name, Asset name, Image IPFS link ). I have tried to get this data from Wallet address ...first using (https://cardano-mainnet.tangocrypto.com/{app_id}/v1/addresses/{address}/assets) which gives me policyId , fingerprint , asset name and these data from first API that i have got used in the all other API's. Second using (https://api.opencnft.io/1/asset/{asset}/tx), third using (https://api.opencnft.io/1/asset/{asset}) and **fourth using (https://api.opencnft.io/1/policy/{policy}/floor_price) which gives. But these all process in taking too much time to fetch the data.

So, is there any particular api which can give all these data or any solution for this?

1 Answer 1

2

My first thought was to go to https://blockfrost.dev/. Here is their API documentation: https://docs.blockfrost.io/. You'll need an API key, but for limited use you can get one for free and test out your scenario.

You can initially get the asset history.

curl -H "project_id: 123456" https://cardano-mainnet.blockfrost.io/api/v0/assets/ad79da159614ff55130b3a28189fbe5c429c0dfc1c0aeaf94a1de95e4b6964646f7330373138/history
[{"tx_hash":"79b99a605b46603dbeefefab83bc72dfc241dafd1236504014732d6c3d3a5195","action":"minted","amount":"1"}]

Grab the transaction hash(s) and then run

curl -H "project_id: 123456" https://cardano-mainnet.blockfrost.io/api/v0/txs/79b99a605b46603dbeefefab83bc72dfc241dafd1236504014732d6c3d3a5195

That will give you a lot of details you won't need, but you can look at output amount:

    "output_amount": [
        {
            "unit": "lovelace",
            "quantity": "19809463"
        },
        {
            "unit": "ad79da159614ff55130b3a28189fbe5c429c0dfc1c0aeaf94a1de95e4b6964646f7330373138",
            "quantity": "1"
        }
    ],

Here you can see that 19809463 lovelace (or 19.8094630 ADA) was spent on unit ...330373138. This is the first transaction, so we might assume this was the purchase price. The same goes for the sold price. If you want the latest sold price, use the latest transaction hash from the /txs api call. Or loop over each to get the price history.

Use whichever language you want for the curl calls, and loop to process the transaction data. Here's a little javascript to grab the tx_hash.

fetch('https://cardano-mainnet.blockfrost.io/api/v0/assets/ad79da159614ff55130b3a28189fbe5c429c0dfc1c0aeaf94a1de95e4b6964646f7330373138/history', {
   headers: {
      'project_id': '123456'
   }
})
   .then(response => response.text())
   .then(text => console.log(JSON.parse(text)[0].tx_hash))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.