How to get complete and fresh NFT metadata

NFT metadata is essentially the soul of an NFT, without it an NFT is nothing more than a record on the chain. That's why access to complete, up-to-date NFT metadata is so critical when creating Web3 experiences involving NFTs. In this tutorial we'll explain how to easily get this valuable component of your user experience with just a single API call. Before jumping into this tutorial we highly recommend getting familiar with unique properties, standards, and challenges associated with NFT metadata.

Mnemonic constantly indexes metadata for over 200 million NFTs (as of the time we wrote this guide) across blockchains and external IPFS and HTTP resources to provide the most fresh up-to-date metadata.

Mnemonic provides not only JSON formatted metadata, but also all kinds of metadata found on or off-chain.

The results provided by our API are normalized into a common schema to make it easy to work with.

Additionally, Mnemonic API provides raw metadata, which is returned in the raw field of the response. The raw value will include any sub-type of and including the text/plain mime-type of the document. Hence, in addition the mimeType field is provided to let the clients know what to expect (in most cases it's going to be application/json).

In order to get full structured metadata of an NFT we can use NFT Details endpoint:

curl -i -X GET \
  'https://ethereum-rest.api.mnemonichq.com/foundational/v1beta2/nfts/0x1a92f7381b9f03921564a437210bb9396471050c/6582/details' \
  -H 'X-API-Key: YOUR_API_KEY_HERE'

The result will look something like this:

{
    "nft": {
        "contractAddress": "0x1a92f7381b9f03921564a437210bb9396471050c",
        "tokenId": "6582",
        "type": "TYPE_ERC721",
        "metadata": {
            "metadataUri": {
                "uri": "https://api.coolcatsnft.com/cat/6582",
                "mimeType": "application/json"
            },
            "name": "Cool Cat #6582",
            "description": "Cool Cats is a collection of 9,999 randomly generated and stylistically curated NFTs that exist on the Ethereum Blockchain. Cool Cat holders can participate in exclusive events such as NFT claims, raffles, community giveaways, and more. Remember, all cats are cool, but some are cooler than others. Visit [www.coolcatsnft.com](https://www.coolcatsnft.com/) to learn more.",
            "image": {
                "uri": "https://ethereum.cdn.mnemonichq.com/0x1a92f7381b9f03921564a437210bb9396471050c/6582/0ef6b7b8775c97c4a6e38c769aa20f49d4320b697708c096c395d7d9789d4763.png",
                "uriOriginal": "https://ipfs.io/ipfs/QmToNpsJgWVdtbrFckzJVVskRrGXcJ6FsS2Gd9maGNWwQ2",
                "mimeType": "image/png"
            }
        },
        "mintEvent": {
            "txHash": "0x88ce45caccf735ee7f78e8c12a1d69381db98e914cc399904777ce7f41b57fc5",
            "logIndex": "52",
            "blockTimestamp": "2021-07-01T22:21:49Z"
        },
        "collection": {
            "name": "Cool Cats"
        }
    },
    "metrics": {
        "quantity": "1",
        "ownerCount": "1"
    },
    "lastSale": {
        "blockchainEvent": {
            "txHash": "0x9f2f52967c3fe0c111a53e30fa4b4cc5171938d860a23e4db067899932f45222",
            "logIndex": "413",
            "seqIndex": "0",
            "blockNumber": "16889817",
            "blockTimestamp": "2023-03-23T11:02:47Z"
        },
        "recipientPaid": {
            "totalNative": "1.3109464088433577",
            "totalUsd": "2301.05854300455887718417495866824",
            "nativeTransfersTotal": "0",
            "fungibleTransfersTotal": "1.3109464088433577",
            "attributedBy": "ATTRIBUTED_BY_SINGLE_TRANSFER",
            "fungibleTotals": [
                {
                    "contractAddress": "0x0000000000a39bb272e79075ade125fd351887ac",
                    "totalNormalized": "1.31"
                }
            ]
        }
    }
}

As you can see, name, description, and image are provided within metadata section, as well as many other details of the NFT, including general metrics and last sale price. However, if you wish to to obtain the full raw metadata you should use NFT Raw Metadata endpoint:

curl --request GET \
     --url https://ethereum-rest.api.mnemonichq.com/foundational/v1beta2/nfts/0xbd3531da5cf5857e7cfaa92426877b022e612cf8/1500/raw_metadata \
     --header 'X-API-Key: <YOUR API KEY>' \
     --header 'accept: application/json'

The response will contain full metadata object, including all properties and other attributes:

{
  "metadata": {
    "raw": "{\"name\": \"Pudgy Penguin #1500\", \"image\": \"https://ipfs.io/ipfs/QmNf1UsmdGaMbpatQ6toXSkzDpizaGmC9zfunCyoz1enD5/penguin/1500.png\", \"attributes\": [{\"value\": \"Blue\", \"trait_type\": \"Background\"}, {\"value\": \"Maroon\", \"trait_type\": \"Skin\"}, {\"value\": \"Tank Top Blue\", \"trait_type\": \"Body\"}, {\"value\": \"Football\", \"trait_type\": \"Face\"}, {\"value\": \"Hat Blue\", \"trait_type\": \"Head\"}], \"description\": \"A collection 8888 Cute Chubby Pudgy Penquins sliding around on the freezing ETH blockchain.\"}",
    "indexedAt": "2022-08-27T14:44:17.736637Z"
  }
}

After you completed this tutorial, let us know about your experience or if you have any feedback by tagging us on Twitter @mnemonichq or reaching out directly to our [email protected]!