Reference NFT API Get NFT metadata This API endpoint allows you to retrieve metadata for a specific NFT based on the contractId
and nftTokenId
. It also supports optional parameters for token ID formatting.
Endpoint Details
Request Response
Query Parameters
Contract ID to get metadata for
the smart contract that the NFT belongs to (See the note above)
NFT token id format. Possible values decimal
or hex
. Defaults to decimal
if it is not specified.
As a prerequisite, you must have one or more NFT contracts that can be managed by your account (see getAccountContracts .
The response will contain the metadata of the specified NFT.
Copy {
result: INftMetadata
| error?: IResponseError // Optional error information
}
export interface INftTraits {
displayType: number,
traitType: string,
value?: any
}
export interface INftMetadata {
externalUrl?: string;
traits: INftTraits[];
name: string;
description: string;
imageUrl: string;
thumbnailUrl?: string;
imageMimeType: string;
thumbnailMimeType?: string;
}
Success result
Copy {
"result": {
"traits": [
{
"displayType": "number",
"traitType": "Member Since",
"value": 2023
},
{
"displayType": "string",
"traitType": "Member Tier",
"value": "Pearl"
}
],
"name": "SMOOTH Pass",
"description": "This pass is your key to unlock rewards and more through Smooth's cutting-edge loyalty platform",
"imageUrl": "https://assets.nft.zelus.io/Smooth-Collectibles-dev/1/image1.png",
"imageMimeType": "image/png",
"externalUrl": "https://zelus.io"
}
}
Error Messages
Incorrect or missing contractId
{ "code": 400, "message": "Contract not found" }
Missing nftTokenId
or invalid format based on tokenIdFormat
{ "code": 404, "message": "NFT not found!" }
Examples
CURL Python NodeJS
Copy curl -X GET 'https://sandbox.api.labs.zelus.io/v1/nft/metadata?contractId=yourContractId&nftTokenId=yourTokenId' \
-H "x-api-key: YOUR_API_KEY"
Copy import requests
url = "https://sandbox.api.labs.zelus.io/v1/nft/metadata"
headers = {
"x-api-key": "YOUR_API_KEY"
}
params = {
"contractId": "yourContractId",
"nftTokenId": "yourTokenId"
}
response = requests.get(url, headers=headers, params=params)
nft_metadata = response.json() # Assuming INftMetadata format
print(f"NFT Metadata: {nft_metadata}")
Copy const axios = require('axios');
const url = "https://sandbox.api.labs.zelus.io/v1/nft/metadata";
const headers = {
"x-api-key": "YOUR_API_KEY"
};
const params = {
contractId: "yourContractId",
nftTokenId: "yourTokenId"
};
axios.get(url, { headers: headers, params: params }).then(response => {
const nft_metadata = response.data; // Assuming INftMetadata format
console.log(`NFT Metadata: ${JSON.stringify(nft_metadata)}`);
}).catch(error => {
console.error('Error:', error.response.data);
});
Notes
Make sure to either provide a contractId
when making the request.
Token ID is always required and its format can be controlled using the tokenIdFormat
parameter.
If using the hex
format for the token ID, ensure it's a valid hexadecimal value.
If a contractId
is used, the base metadata URL retrieved from it combined with the token ID will be used to fetch the metadata.