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
Headers
Content-Type
application/json
x-api-key
API_KEY
Query Parameters
contractId
string
Contract ID to get metadata for
nftTokenId
string
the smart contract that the NFT belongs to (See the note above)
tokenIdFormat
string, optional
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.
{
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
{
"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
nftTokenIdor invalid format based ontokenIdFormat{ "code": 404, "message": "NFT not found!" }
Examples
curl -X GET 'https://sandbox.api.labs.zelus.io/v1/nft/metadata?contractId=yourContractId&nftTokenId=yourTokenId' \
-H "x-api-key: YOUR_API_KEY"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}")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
contractIdwhen making the request.Token ID is always required and its format can be controlled using the
tokenIdFormatparameter.If using the
hexformat for the token ID, ensure it's a valid hexadecimal value.If a
contractIdis used, the base metadata URL retrieved from it combined with the token ID will be used to fetch the metadata.
Last updated
Was this helpful?