> For the complete documentation index, see [llms.txt](https://docs.piperx.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.piperx.xyz/developer/sdks/fetch-price-data.md).

# Fetch Price Data

## Fetch Price Feed data for pool

You could fetch real-time price data for a given pool

<pre class="language-typescript"><code class="lang-typescript">import { v2GetPrice, v2GetPriceWithDecimals } from '@piperx/sdk/src/core'
import { v3GetPrice, v3GetPriceWithDecimals } from '@piperx/sdk/src/core'


<strong>price = v2GetPrice(
</strong>    token1: string, // token 1 address
    token2: string, // token 2 address
) 

<strong>price = v2GetPriceWithDecimals(
</strong>    token1: string,
    token2: string,
    decimal1: number,
    decimal2: number
) 

price = v3GetPrice(
    token1: string, // token 1 address
    token2: string, // token 2 address
    fee: number, // 500, 3000, 10000 represent 0.05%, 0.3%, 1% fee
) 

price = v3GetPriceWithDecimals(
    token1: string,
    token2: string,
    decimal1: number,
    decimal2: number,
    fee: number, // 500, 3000, 10000 represent 0.05%, 0.3%, 1% fee
) 
</code></pre>

We have four APIs for fetching the price. The `v2GetPrice` and `v3GetPrice` will return the real price (1 token1 = X token2) based on the token amount in contract (not considering decimal). If you want the user-facing price, you should use `v2GetPriceWithDecimals and v3GetPriceWithDecimals`. However, you have to pass the decimals of both tokens.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.piperx.xyz/developer/sdks/fetch-price-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
