getNFTMetadata
Gets the metadata associated with a given NFT.
NOTE: This endpoint offers multi-chain support. Check chains currently available for the NFT API.

Parameters

  • contractAddress: address of NFT contract
  • tokenId: Id for NFT (integer)
  • tokenType : (optional) "ERC721" or "ERC1155" , type of token
    • request may perform faster if this parameter is specified

Returns

  • JSON Object containing the following fields and potentially more fields.
    • contract: contract for returned NFT
      • address: address of NFT contract
    • id
      • tokenId: Id for NFT (integer)
      • tokenMetadata
        • tokenType: "ERC721" or "ERC1155"
    • tokenUri:
      • raw: uri representing the location of the NFT's original metadata blob. This is a backup for you to parse when the metadata field is not automatically populated.
      • gateway: public gateway uri for the raw uri above.
    • metadata: [NOT GUARANTEED*] relevant metadata for NFT contract. This is useful for viewing image url, traits, etc. without having to follow the metadata blob url in tokenUri to parse manually.
    • timeLastUpdated: ISO timestamp of the last cache refresh for the information returned in the metadata field.
*Note on metadata
Some NFT contracts may not have metadata specified. You may need to parse the response on a case by case basis.

Example

Version

You must update your api_key from your dashboard from V2 --> V1, ie
https://eth-mainnet.g.alchemy.com/your-api-key/v2 should be https://eth-mainnet.g.alchemy.com/your-api-key/v1

Network

The example below is for Ethereum Mainnet. If you are using Polygon you'll need to use your polygon endpoint instead: https://polygon-mainnet.g.alchemy.com/your-api-key/v1/getNFTs...

Request

Curl
JavaScript - Fetch
JavaScript - jQuery
Postman
1
curl 'https://eth-mainnet.g.alchemy.com/your-api-key/v1/getNFTMetadata?contractAddress=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d&tokenId=2&tokenType=erc721&&refreshCache=true'
Copied!
1
var requestOptions = {
2
method: 'GET',
3
redirect: 'follow'
4
};
5
6
fetch("https://eth-mainnet.g.alchemy.com/demo/v1/getNFTMetadata?contractAddress=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d&tokenId=2&tokenType=erc721&refreshCache=true", requestOptions)
7
.then(response => response.text())
8
.then(result => console.log(result))
9
.catch(error => console.log('error', error));
Copied!
1
var settings = {
2
"url": "https://eth-mainnet.g.alchemy.com/demo/v1/getNFTMetadata?contractAddress=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d&tokenId=2&tokenType=erc721&refreshCache=true",
3
"method": "GET",
4
"timeout": 0,
5
};
6
7
$.ajax(settings).done(function (response) {
8
console.log(response);
9
});
Copied!
1
URL: https://eth-mainnet.g.alchemy.com/demo/v1/getNFTMetadata?contractAddress=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d&tokenId=2&tokenType=erc721&refreshCache=true
2
RequestType: GET
Copied!

Response

1
{
2
"contract": {
3
"address": "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d"
4
},
5
"id": {
6
"tokenId": "2",
7
"tokenMetadata": {
8
"tokenType": "ERC721"
9
}
10
},
11
"title": "",
12
"description": "",
13
"tokenUri": {
14
"raw": "ipfs://QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/2",
15
"gateway": "https://ipfs.io/ipfs/QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/2"
16
},
17
"media": [
18
{
19
"uri": {
20
"raw": "ipfs://QmcJYkCKK7QPmYWjp4FD2e3Lv5WCGFuHNUByvGKBaytif4",
21
"gateway": "https://ipfs.io/ipfs/QmcJYkCKK7QPmYWjp4FD2e3Lv5WCGFuHNUByvGKBaytif4"
22
}
23
}
24
],
25
"metadata": {
26
"image": "ipfs://QmcJYkCKK7QPmYWjp4FD2e3Lv5WCGFuHNUByvGKBaytif4",
27
"attributes": [
28
{
29
"value": "3d",
30
"trait_type": "Eyes"
31
},
32
{
33
"value": "Bored Cigarette",
34
"trait_type": "Mouth"
35
},
36
{
37
"value": "Robot",
38
"trait_type": "Fur"
39
},
40
{
41
"value": "Sea Captain's Hat",
42
"trait_type": "Hat"
43
},
44
{
45
"value": "Aquamarine",
46
"trait_type": "Background"
47
}
48
]
49
},
50
"timeLastUpdated": "2022-01-25T19:56:50.580Z"
51
}
Copied!
Last modified 3d ago