# Fetch Price

The `Fetch Price` tool, part of AgentiPy, allows users to fetch the price of a given token in USDC by querying the Jupiter API (`https://api.jup.ag/price/v2`). It's a simple way to get current price data for a specific token mint address on Solana.

## Functionality

This tool is implemented in the `TokenPriceFetcher` class.

### Key Methods:

* `fetch_price(token_id: str) -> str`:
  * Takes a `token_id` (the token mint address as a string) as input.
  * Constructs a URL to query the Jupiter API.
  * Uses `aiohttp` to make an asynchronous GET request to the API.
  * Parses the JSON response to extract the price of the token in USDC.
  * Returns the price as a string.
  * Raises an exception if the API request fails, the response status is not 200, or if price data for the token is not available in the response.

##

**Note:** This tool relies on the public Jupiter API. Availability and rate limits of the API are determined by Jupiter Aggregator. The returned price is typically in USDC.

## Source Code

You can find the source code for this tool on GitHub: <https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/fetch_price.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/fetch-price.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.
