Zelus Labs API
  • Welcome!
  • Features
  • Quick Start
  • Reference
    • OpenAPI
    • Account API
      • Account Status
      • Account Contracts
    • Wallet API
      • Wallet Create
      • Wallet Balance
      • Wallet NFTs
    • NFT API
      • Minting an NFT
      • Get NFT metadata
Powered by GitBook
On this page
  • Endpoint Details
  • Examples
  • Notes

Was this helpful?

  1. Reference
  2. NFT API

Get NFT metadata

PreviousMinting an NFT

Last updated 1 year ago

Was this helpful?

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

Description
Data

API Name

HTTP Method

GET

URL

/v1/nft/metadata

Headers

Key
Value

Content-Type

application/json

x-api-key

API_KEY

Query Parameters

Parameter
Type
Description

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 .

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 nftTokenId or invalid format based on tokenIdFormat

    • { "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 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.

getAccountContracts
getNftMetadata