The Helius Digital Asset Standard (DAS) API provides powerful tools for reading and querying both NFT and token data on Solana. This guide shows you how to work with different types of Solana assets effectively.
Price Data for Jupiter Verified Tokens
const fetchTokenPriceData = async () => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: "POST" ,
headers: {
"Content-Type" : "application/json" ,
},
body: JSON . stringify ({
jsonrpc: "2.0" ,
id: "1" ,
method: "getAsset" ,
params: {
id: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" , // Bonk token mint address
displayOptions: {
showFungibleTokens: true
}
},
}),
});
const data = await response . json ();
// Calculate market cap
if ( data . result ?. token_info ?. price_info ) {
const { price_per_token } = data . result . token_info . price_info ;
const { supply , decimals } = data . result . token_info ;
// Adjust supply for decimals
const adjustedSupply = supply / Math . pow ( 10 , decimals );
const marketCap = price_per_token * adjustedSupply ;
console . log ( `Market Cap: $ ${ marketCap . toLocaleString () } ` );
}
return data ;
};
API Reference View detailed documentation for getAsset
Response Structure
The price data is available in the response under token_info.price_info
:
{
"token_info" : {
"symbol" : "Bonk" ,
"supply" : 8881594973561640000 ,
"decimals" : 5 ,
"token_program" : "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" ,
"price_info" : {
"price_per_token" : 0.0000192271 ,
"currency" : "USDC"
}
}
}
Calculating Market Cap
To calculate a token’s market cap, multiply its price by the adjusted supply (accounting for decimals):
const adjustedSupply = supply / Math . pow ( 10 , decimals );
const marketCap = pricePerToken * adjustedSupply ;
This calculation gives you the total market valuation of the token by properly accounting for the token’s decimal places.
Working with NFTs and Digital Collectibles
The DAS API offers several methods for working with NFTs and digital collectibles. These methods allow you to retrieve individual assets, query by owner or creator, and verify on-chain authenticity.
Get Single NFT Find by Owner Advanced Search Getting a Single NFT Retrieve comprehensive data for a specific NFT:
const getNFT = async ( mintAddress ) => {
const response = await fetch ( 'https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY' , {
method: "POST" ,
headers: {
"Content-Type" : "application/json" ,
},
body: JSON . stringify ({
jsonrpc: "2.0" ,
id: "1" ,
method: "getAsset" ,
params: {
id: mintAddress ,
},
}),
});
const data = await response . json ();
return data ;
};
// Example usage
getNFT ( "F9Lw3ki3hJ7PF9HQXsBzoY8GyE6sPoEZZdXJBsTTD2rk" );
Getting a Single NFT Retrieve comprehensive data for a specific NFT:
const getNFT = async ( mintAddress ) => {
const response = await fetch ( 'https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY' , {
method: "POST" ,
headers: {
"Content-Type" : "application/json" ,
},
body: JSON . stringify ({
jsonrpc: "2.0" ,
id: "1" ,
method: "getAsset" ,
params: {
id: mintAddress ,
},
}),
});
const data = await response . json ();
return data ;
};
// Example usage
getNFT ( "F9Lw3ki3hJ7PF9HQXsBzoY8GyE6sPoEZZdXJBsTTD2rk" );
Finding NFTs by Owner Retrieve all NFTs owned by a specific wallet address:
const getNFTsByOwner = async ( ownerAddress ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: "POST" ,
headers: {
"Content-Type" : "application/json" ,
},
body: JSON . stringify ({
jsonrpc: "2.0" ,
id: "1" ,
method: "getAssetsByOwner" ,
params: {
ownerAddress: ownerAddress ,
page: 1 ,
limit: 10 ,
},
}),
});
const data = await response . json ();
return data ;
};
// Example usage
getNFTsByOwner ( "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY" );
Searching Assets with Advanced Filters Search for assets by various attributes with detailed filters:
const searchAssets = async ( params ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: "POST" ,
headers: {
"Content-Type" : "application/json" ,
},
body: JSON . stringify ({
jsonrpc: "2.0" ,
id: "1" ,
method: "searchAssets" ,
params: params ,
}),
});
const data = await response . json ();
return data ;
};
// Example: Find all NFTs owned by an address
searchAssets ({
ownerAddress: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY" ,
tokenType: "all" ,
limit: 50 ,
});
Advanced NFT Query Methods
By Creator By Collection Transaction History On-Chain Proof const getAssetsByCreator = async ( creatorAddress ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: "POST" ,
headers: {
"Content-Type" : "application/json" ,
},
body: JSON . stringify ({
jsonrpc: "2.0" ,
id: "1" ,
method: "getAssetsByCreator" ,
params: {
creatorAddress: creatorAddress ,
page: 1 ,
limit: 100 ,
},
}),
});
const data = await response . json ();
return data ;
};
// Example usage
getAssetsByCreator ( "9uBX3ASjxWvNBAD1xjbVaKA74mWGZys3RGSF7DdeDD3F" );
const getAssetsByCreator = async ( creatorAddress ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: "POST" ,
headers: {
"Content-Type" : "application/json" ,
},
body: JSON . stringify ({
jsonrpc: "2.0" ,
id: "1" ,
method: "getAssetsByCreator" ,
params: {
creatorAddress: creatorAddress ,
page: 1 ,
limit: 100 ,
},
}),
});
const data = await response . json ();
return data ;
};
// Example usage
getAssetsByCreator ( "9uBX3ASjxWvNBAD1xjbVaKA74mWGZys3RGSF7DdeDD3F" );
const getAssetsByCollection = async ( collectionAddress ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: "POST" ,
headers: {
"Content-Type" : "application/json" ,
},
body: JSON . stringify ({
jsonrpc: "2.0" ,
id: "1" ,
method: "getAssetsByGroup" ,
params: {
groupKey: "collection" ,
groupValue: collectionAddress ,
page: 1 ,
limit: 100 ,
},
}),
});
const data = await response . json ();
return data ;
};
// Example usage
getAssetsByCollection ( "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w" );
const getNFTTransactionHistory = async ( mintAddress ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: "POST" ,
headers: {
"Content-Type" : "application/json" ,
},
body: JSON . stringify ({
jsonrpc: "2.0" ,
id: "1" ,
method: "getSignaturesForAsset" ,
params: {
id: mintAddress ,
page: 1 ,
limit: 100 ,
},
}),
});
const data = await response . json ();
return data ;
};
// Example usage
getNFTTransactionHistory ( "FNt6A9Mfnqbwc1tY7uwAguKQ1JcpBrxmhczDgbdJy5AC" );
const getNFTProof = async ( mintAddress ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: "POST" ,
headers: {
"Content-Type" : "application/json" ,
},
body: JSON . stringify ({
jsonrpc: "2.0" ,
id: "1" ,
method: "getAssetProof" ,
params: {
id: mintAddress ,
},
}),
});
const proof = await response . json ();
return proof ;
};
// Example usage
getNFTProof ( "Bu1DEKeawy7txbnCEJE4BU3BKLXaNAKCYcHR4XhndGss" );
Working with SPL Tokens
SPL tokens can be queried through multiple methods in the Helius API. These methods let you check balances, find token accounts, and get token metadata.
Common SPL Token Operations
Token Balance Tokens by Owner Token Supply Largest Holders const getTokenBalance = async ( tokenAccountAddress ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: 'POST' ,
headers: { 'Content-Type' : 'application/json' },
body: JSON . stringify ({
jsonrpc: '2.0' ,
id: '1' ,
method: 'getTokenAccountBalance' ,
params: [ tokenAccountAddress ]
})
});
const data = await response . json ();
return data ;
};
// Example usage
getTokenBalance ( "3emsAVdmGKERbHjmGfQ6oZ1e35dkf5iYcS6U4CPKFVaa" );
API Reference View getTokenAccountBalance documentation
const getTokenBalance = async ( tokenAccountAddress ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: 'POST' ,
headers: { 'Content-Type' : 'application/json' },
body: JSON . stringify ({
jsonrpc: '2.0' ,
id: '1' ,
method: 'getTokenAccountBalance' ,
params: [ tokenAccountAddress ]
})
});
const data = await response . json ();
return data ;
};
// Example usage
getTokenBalance ( "3emsAVdmGKERbHjmGfQ6oZ1e35dkf5iYcS6U4CPKFVaa" );
API Reference View getTokenAccountBalance documentation
const getTokensByOwner = async ( ownerAddress ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: 'POST' ,
headers: { 'Content-Type' : 'application/json' },
body: JSON . stringify ({
jsonrpc: '2.0' ,
id: '1' ,
method: 'getTokenAccountsByOwner' ,
params: [
ownerAddress ,
{
programId: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
},
{
encoding: 'jsonParsed'
}
]
})
});
const data = await response . json ();
return data ;
};
// Example usage
getTokensByOwner ( "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY" );
API Reference View getTokenAccountsByOwner documentation
const getTokenSupply = async ( mintAddress ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: 'POST' ,
headers: { 'Content-Type' : 'application/json' },
body: JSON . stringify ({
jsonrpc: '2.0' ,
id: '1' ,
method: 'getTokenSupply' ,
params: [ mintAddress ]
})
});
const data = await response . json ();
return data ;
};
// Example usage
getTokenSupply ( "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" );
API Reference View getTokenSupply documentation
const getTokenLargestAccounts = async ( mintAddress ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: 'POST' ,
headers: { 'Content-Type' : 'application/json' },
body: JSON . stringify ({
jsonrpc: '2.0' ,
id: '1' ,
method: 'getTokenLargestAccounts' ,
params: [ mintAddress ]
})
});
const data = await response . json ();
return data ;
};
// Example usage
getTokenLargestAccounts ( "he1iusmfkpAdwvxLNGV8Y1iSbj4rUy6yMhEA3fotn9A" );
API Reference View getTokenLargestAccounts documentation
Advanced SPL Token Queries
You can also find all accounts holding a specific token mint:
const getTokenAccountsByMint = async ( mintAddress ) => {
const response = await fetch ( "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY" , {
method: 'POST' ,
headers: { 'Content-Type' : 'application/json' },
body: JSON . stringify ({
jsonrpc: '2.0' ,
id: '1' ,
method: 'getTokenAccountsByOwner' ,
params: [
'CEXq1uy9y15PL2Wb4vDQwQfcJakBGjaAjeuR2nKLj8dk' , // Owner address
{
mint: mintAddress
},
{
encoding: 'jsonParsed'
}
]
})
});
const data = await response . json ();
return data ;
};
// Example usage
getTokenAccountsByMint ( "8wXtPeU6557ETkp9WHFY1n1EcU6NxDvbAggHGsMYiHsB" );
Best Practices
When working with the DAS API, keep these best practices in mind:
Use pagination for methods that return large data sets
Handle errors gracefully by implementing try/catch blocks
Cache responses when appropriate to reduce API calls
Respect rate limits to avoid disruptions in your application
Verify Jupiter price data is available before calculating market cap
FAQ
How do I get all NFTs for a wallet?
Use the getAssetsByOwner
method with the wallet address. Be sure to implement pagination if the wallet might contain many assets.
Can I get price data for any token?
Price data is only available for tokens that are verified on Jupiter. Check if token_info.price_info
exists in the response.
How do I find the largest holders of a token?
Use the getTokenLargestAccounts
method with the token’s mint address to retrieve a list of the largest holder accounts.
What's the difference between getAsset and searchAssets?
getAsset
retrieves data for a single asset by its mint address, while searchAssets
allows you to query multiple assets using various filters.