> For the complete documentation index, see [llms.txt](https://skylar-1.gitbook.io/skylar/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://skylar-1.gitbook.io/skylar/capabilities/token-analyzer.md).

# Token Analyzer

The **Token Analyzer** function allows you to analyze any cryptocurrency by coins being sent to its native address. In this example, it fetches data for **Bitcoin** by default, but you can specify other coins (e.g., `ethereum` for Ethereum) by passing the appropriate coin ID to the `coin_id` parameter through detecting sent coins. The function constructs the **API request URL**, sends a `GET` request to the **CoinGecko API**, and processes the response as a JSON object. If the response contains an error (e.g., an invalid coin ID), the function will print an error message and return `None`. Otherwise, it extracts essential details such as the **coin's name**, **symbol**, **current price** (in USD), **market capitalization**, and **24-hour price change percentage**. These details are organized in a dictionary called `coin_info`, which is then returned to the user. This function is particularly useful for integrating live market data into applications or bots that require **real-time cryptocurrency information** for analysis, trading, or monitoring.

```python
def fetch_coin_data(coin_id="bitcoin"):
    url = f"{COINGECKO_API_URL}coins/{coin_id}"
    response = requests.get(url)
    data = response.json()
    
    if 'error' in data:
        print(f"Error fetching data: {data['error']}")
        return None

    # Coin Information
    coin_info = {
        "name": data["name"],
        "symbol": data["symbol"],
        "current_price": data["market_data"]["current_price"]["usd"],
        "market_cap": data["market_data"]["market_cap"]["usd"],
        "24h_change": data["market_data"]["price_change_percentage_24h"]
    }
    
    return coin_info
```
