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.

The Helius API does not verify SPL-20 tokens. Trade at your own risk. For more information, please use the validator tool or join the Libreplex Discord channel.

Examples

Searching for all Fungible Tokens in a wallet:

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',
	    tokenType: 'fungible',
      },
    }),
  });
  const { result } = await response.json();
  console.log("Search Assets: ", result);
};
searchAssets();

Searching for all Fungible Tokens (showing native balance and token info):

const url = `https://mainnet.helius-rpc.com/?api-key=<api_key>`

const searchAssetsTokenInfo = 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();

    result.items.forEach(item => {  // for each item in the result, log the token_info
      console.log(item.token_info);
  });

    console.log("Native Balance: ", result.nativeBalance); // logging native balance
};

searchAssetsTokenInfo();

Searching for Drip NFTs owned by vibhu.sol

const url = `https://mainnet.helius-rpc.com/?api-key=<api_key>`

const searchAssetsDrip = 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: 'BAVjpySHMMGDpq3whU7qaqCCRE8ksCeGwxa53Qv2i8jS',
        grouping: ["collection", "DRiP2Pn2K6fuMLKQmt5rZWyHiUZ6WK3GChEySUpHSS4x"],
        page: 1, // Starts at 1
        limit: 1000
      },
    }),
  });
  const { result } = await response.json();
  console.log("Drip Haus Assets: ", result);
};
searchAssetsDrip();

Searching for Compressed Assets in a wallet:

const url = `https://mainnet.helius-rpc.com/?api-key=<api_key>`

const searchAssetsCompressed = 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);
};
searchAssetsCompressed();

Searching for Inscriptions & SPL-20 data

const url = `https://mainnet.helius-rpc.com/?api-key=<api-key>`

const searchAssetsInscriptions = 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]));
};
searchAssetsInscriptions();

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:

  • creatorAddress

  • creatorVerified

  • grouping

  • ownerType

  • specificationAssetClass

  • compressed

  • compressible

  • specificationVersion

  • authorityAddress

  • delegate

  • frozen

  • supply

  • supplyMint

  • royalty (and related fields: royaltyTargetType, royaltyTarget, royaltyAmount)

  • burnt

  • jsonUri

  • collections

  • name

Last updated