How can I go about getting a NFT’s metadata, like image link, from its IPFS url or its ARC id, both of which I have. I want to retrieve this info in javascript, fetch does not work for IPFS addresses. Let me know if anyone knows how to solve this, thanks!
You need to use an IPFS gateway.
See IPFS Gateway | IPFS Docs
For example, for this ARC69 NFT: Algorand
the URL of the asset is:
ipfs://QmeRgH3a5BYXer6X3KwEpFedTFXz8svSpfC84FvRR3MXSd
and you can access it through the gateway, such as:
Important note: Public gateways need to be trusted by you: IPFS Gateway | IPFS Docs
@fabrice can you elaborate on how you constructed the URL for the asset given the NFT information you linked to in AlgoExplorer please?
@zorev To download the png file and rename the file mngo.png:
$ curl -G https://ipfs.io/ipfs/QmeRgH3a5BYXer6X3KwEpFedTFXz8svSpfC84FvRR3MXSd --output mngo.png
To get the cid hash of the file you downloaded and renamed mngo.png, you need to use Kubo CLI | IPFS Docs
$ ipfs add --cid-version 0 --hash sha2-256 -q -n mngo.png
output will be QmeRgH3a5BYXer6X3KwEpFedTFXz8svSpfC84FvRR3MXSd
--cid-version 0 --hash sha2-256
are default values foripfs add
. I just added them to make it clearer
-n is here to display the generated hash without pining the file to your IPFS node.
You can also find more information here: Pin files | IPFS Docs