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 Tokens
Price data returned by getAsset is cached and may not be fresh. The price information has a 60-second cache, meaning the data can be up to 60 seconds old.
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" );
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" );
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
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 price data is available before calculating market cap
Questions?
For frequently asked questions about the DAS API including asset data, price information, and API usage, visit our comprehensive DAS API FAQ .