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