Search Assets Search for assets using a variety of parameters.
Overview
This method will return assets based on the custom search criteria passed in. This can define compressed, regular NFTs, and fungible tokens.
This method is optimal for most custom use cases. Example: token gating.
The page
parameter in the request starts at 1.
Fungible Token Extension
DAS API traditionally has only returned data for NFTs — at Helius, we've also added support for all tokens. Developers can access this feature query by setting tokenType
to all
.
Fungible tokens will include their associated information (decimals, supply, and price). Token22 tokens are also supported and their extensions are parsed. We also display native balances if you enable the showNativeBalance
flag.
The options for tokenType
include:
fungible
: Returns all fungible tokens.
nonFungible
: Returns all NFTs (compressed and regular NFTs).
regularNFT
: Returns only the regular NFTs.
compressedNFT
: Returns only the compressed NFTs.
all
: Returns all the tokens.
To learn more, please visit Fungible Token Extension (Beta) .
Not all options within searchAssets are supported with tokenType
. Please read here to learn more.
Inscriptions & SPL-20
You can optionally display inscription and SPL-20 token data with the showInscription
flag. You can learn more about inscriptions and SPL-20 here .
Please note that this is an experimental feature.
Examples
Search for Drip NFTs owned by toly.sol
Copy const url = `https://mainnet.helius-rpc.com/?api-key=<api_key>`
const searchAssets = async () => {
const response = await fetch (url , {
method : 'POST' ,
headers : {
'Content-Type' : 'application/json' ,
} ,
body : JSON .stringify ({
jsonrpc : '2.0' ,
id : 'my-id' ,
method : 'searchAssets' ,
params : {
ownerAddress : '86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY' ,
grouping : [ "collection" , "DRiP2Pn2K6fuMLKQmt5rZWyHiUZ6WK3GChEySUpHSS4x" ] ,
page : 1 , // Starts at 1
limit : 1000
} ,
}) ,
});
const { result } = await response .json ();
console .log ( "Drip Haus Assets: " , result);
};
searchAssets ();
Searching for compressed assets in a wallet:
Copy const url = `https://mainnet.helius-rpc.com/?api-key=<api_key>`
const searchAssets = async () => {
const response = await fetch (url , {
method : 'POST' ,
headers : {
'Content-Type' : 'application/json' ,
} ,
body : JSON .stringify ({
jsonrpc : '2.0' ,
id : 'my-id' ,
method : 'searchAssets' ,
params : {
ownerAddress : '2k5AXX4guW9XwRQ1AKCpAuUqgWDpQpwFfpVFh3hnm2Ha' ,
compressed : true ,
} ,
}) ,
});
const { result } = await response .json ();
console .log ( "Search Assets: " , result);
};
searchAssets ();
Searching for all fungible tokens in a wallet:
Copy const url = `https://mainnet.helius-rpc.com/?api-key=<api_key>`
const searchAssets = async () => {
const response = await fetch (url , {
method : 'POST' ,
headers : {
'Content-Type' : 'application/json' ,
} ,
body : JSON .stringify ({
jsonrpc : '2.0' ,
id : 'my-id' ,
method : 'searchAssets' ,
params : {
ownerAddress : '2k5AXX4guW9XwRQ1AKCpAuUqgWDpQpwFfpVFh3hnm2Ha' ,
tokenType : fungible
} ,
}) ,
});
const { result } = await response .json ();
console .log ( "Search Assets: " , result);
};
searchAssets ();
Searching for all assets (including native balance):
Copy const url = `https://mainnet.helius-rpc.com/?api-key=<api_key>`
const getAssetsWithNativeBalance = async () => {
const response = await fetch (url , {
method : 'POST' ,
headers : {
'Content-Type' : 'application/json' ,
} ,
body : JSON .stringify ({
jsonrpc : '2.0' ,
id : 'my-id' ,
method : 'searchAssets' ,
params : {
ownerAddress : '86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY' ,
tokenType : 'fungible' ,
displayOptions : {
showNativeBalance : true ,
} ,
} ,
}) ,
});
const { result } = await response .json ();
console .log ( result . nativeBalance .lamports); // 1479920100
console .log ( result . nativeBalance .price_per_sol); // 59.98567343
console .log ( result . nativeBalance .total_price); // 88.77400382109295
};
getAssetsWithNativeBalance ();
Show inscriptions & SPL-20 data
Copy const url = `https://mainnet.helius-rpc.com/?api-key=<api-key>` ;
const getAssetsWithInscriptions = async () => {
const response = await fetch (url , {
method : 'POST' ,
headers : {
'Content-Type' : 'application/json' ,
} ,
body : JSON .stringify ({
jsonrpc : '2.0' ,
id : 'my-id' ,
method : 'searchAssets' ,
params : {
ownerAddress : '6GmTFg5SCs4zGfDEidUAJjS5pSrXEPwW8Rpfs3RHrbc5' ,
tokenType : 'regularNft' ,
displayOptions : {
showInscription : true , // display inscription & spl-20 data
} ,
} ,
}) ,
});
const { result } = await response .json ();
console .log ( result . items .map ((i) => [ i .id , i .inscription , i .spl20]));
};
getAssetsWithInscriptions ();
// Example output:
// [
// [
// 'AKo9P7S8FE9NYeAcrtZEpimwQAXJMp8Lrt8p4dMkHkY2',
// {
// order: 308332,
// size: 52,
// contentType: 'application/text',
// encoding: 'base64',
// validationHash: '907e00a18f952ade319c21b90764e5d0a08ec31c92e792f806a995e8524535ca',
// inscriptionDataAccount: '9qM9ThkVPxjq4TyBjCs1qpY15VYVim2Qh7uR5yG1Da3T',
// },
// { p: 'spl-20', op: 'mint', tick: 'helius', amt: '1' },
// ],
// ];
Using the Token Support Extension
When using the tokenType
as a filter, it is mandatory to also include the ownerAddress
filter.
Is your query not supported? We'd like to know! Reach out to us on Discord on Telegram, and we'll help you out.
If the tokenType
field is set to fungible
or all
the following filters can't be used:
royalty
(and related fields: royaltyTargetType
, royaltyTarget
, royaltyAmount
)
Last updated 4 months ago