NFT Metadata
Get NFT metadata using the getAsset DAS API. Returns image, attributes, collection info, royalties, and creator details.
Try It
Code Example
// Get NFT metadata by mint address
import { Helius } from 'helius-sdk';
const helius = new Helius('YOUR_API_KEY');
async function getNftMetadata(mintAddress: string) {
const asset = await helius.getAsset({
id: mintAddress,
displayOptions: {
showCollectionMetadata: true
}
});
return {
name: asset.content?.metadata?.name,
image: asset.content?.links?.image,
collection: asset.grouping?.find(g => g.group_key === 'collection'),
owner: asset.ownership?.owner,
royalty: asset.royalty?.percent
};
}
// Usage - Mad Lads #8420
const nft = await getNftMetadata('F9Lw3ki3hJ7PF9HQXsBzoY8GyE6sPoEZZdXJBsTTD2rk');
console.log(`NFT: ${nft.name}`);
console.log(`Owner: ${nft.owner}`);API Tips
- Collection metadata: Include
showCollectionMetadata: trueto get collection name, image, and verification status. - Unverified collections: Use
showUnverifiedCollections: trueif you want to see unverified collection groupings. - Token types: This endpoint handles standard NFTs, programmable NFTs (pNFTs), and legacy SPL tokens.
Frequently Asked Questions
How do I get NFT metadata on Solana?
Use the getAsset DAS API with the NFT mint address. It returns metadata including name, image, attributes, collection info, royalties, and creator details in a single call.
What is the difference between standard NFTs and pNFTs?
Programmable NFTs (pNFTs) have additional on-chain rules enforced by the Token Metadata program, like royalty enforcement. The getAsset API handles both types - check the interface field to distinguish them.
How do I get collection information for an NFT?
Include showCollectionMetadata: true in displayOptions. The collection info will appear in the grouping array with group_key set to "collection".