# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.agentipy.fun/tools/get-token-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
