Retrieve All Tags

Tokens can also be filtered by tags. To retrieve a list of all available tags, use the /tokens/tags endpoint.

 curl  --header 'X-API-Key: <YOUR API KEY>  'https://svc.blockdaemon.com/defi/tokens/tags' | jq

You should see a response listing all available tags similar to this:

[  
  "native",  
  "stablecoin",  
  "staking",  
  "defi",  
  "meme",  
  "gamefi",  
  "metaverse",  
  "nft"  
]

Filter Tokens by Tag

To filter the token list by a specific tag, use the tagLimit parameter. For example, to fetch stablecoins:

curl  --header 'X-API-Key: <YOUR API KEY>' '<https://svc.blockdaemon.com/defi/tokens?tagLimit=stablecoin'> | jq

To query with tags programmatically, use the filters as shown above.

// Prepare the filters  
const parameters = {  
	chainID: "1", // Fetch from Ethereum only  
	token: undefined,  
	tokenSymbol: undefined,  
	tagLimit: ["native", "stablecoin"] // Fetch native tokens only  
}

Code Example

This guide builds onto Get Supported Tokens and Their Metadata to explain how to utilise tags when querying token data.

Let’s go through the relevant code sections step by step:

  1. First we query and log all available tags.
    const tags = await api.getTokenTags();
    log.info("Available tags")
    log.info(JSON.stringify(tags, null, 2));
    
  2. Next we create a parameter object which combines a tag with the chain id for Ethereum to return only stablecoins on Ethereum Mainnet.
    const tokensParameters: GetTokensRequest = {
      tagLimit: ["stablecoin"],
      chainID: "1"
    };
    
  3. Finally we query the API and log the returned data:
    const someTokens = await api.getTokens(tokensParameters);
    log.info("Got Ethereum Stablecoins");
    log.info(JSON.stringify(someTokens, null, 2));
    

πŸ‘‹ Need Help?

Contact us through email or our support page for any issues, bugs, or assistance you may need.