Get Token Data

The Get Token Data tool, part of AgentiPy, allows users to retrieve information about SPL tokens on the Solana blockchain. It can fetch token details using either the token's mint address (from Jupiter's token list) or its ticker symbol (from DexScreener).

Functionality

This tool is implemented in the TokenDataManager class.

Key Methods:

  • get_token_data_by_address(mint: Pubkey) -> Optional[JupiterTokenData]:

    • Takes a token mint address (solders.pubkey.Pubkey object).

    • Fetches a list of verified tokens from Jupiter's token API (https://tokens.jup.ag/tokens?tags=verified).

    • Searches for the token with the matching mint address in the list.

    • Returns a JupiterTokenData object (containing address, symbol, name) if found, otherwise None.

  • get_token_address_from_ticker(ticker: str) -> Optional[str]:

    • Takes a token ticker symbol (e.g., "SOL", "USDC").

    • Queries the DexScreener API (https://api.dexscreener.com/latest/dex/search) for pairs matching the ticker.

    • Filters for Solana pairs and sorts them, prioritizing those with higher Fully Diluted Valuation (FDV).

    • Returns the base token's mint address (string) for the best matching Solana pair if found, otherwise None.

  • get_token_data_by_ticker(ticker: str) -> Optional[JupiterTokenData]:

    • First calls get_token_address_from_ticker to resolve the ticker to a mint address.

    • If an address is found, it then calls get_token_data_by_address with that address.

    • Returns a JupiterTokenData object or None.

Note: This tool relies on external APIs (Jupiter and DexScreener). Their availability and rate limits apply.

Source Code

You can find the source code for this tool on GitHub: https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/get_token_data.py

Last updated