> For the complete documentation index, see [llms.txt](https://docs.coinvera.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coinvera.io/integration/solana/get-price-by-pool.md).

# Get Price By Pool

Retrieve the real-time price of a specific token from any supported DEX pool. This is ideal when you need precision pricing or want to target a particular liquidity pool for lowest latency.

**Endpoint**

```
GET https://api.coinvera.io/api/v1/price
```

**Authentication**\
Include your API key in the request header:

```
x-api-key: <YOUR_API_KEY>
```

**Query Parameters**

* `ca` (string, required) — The token’s mint address.
* `poolId` (string, required) — The identifier of the liquidity pool you want to query.

**Direct URL Example**

```
https://api.coinvera.io/api/v1/price?ca=<TOKEN_MINT>&poolId=<POOL_ID>&x-api-key=<YOUR_API_KEY>
```

**Code Examples**

{% tabs %}
{% tab title="Nodejs" %}

```javascript
const axios = require('axios');

const x_api_key = "";

// Add your token addresses and pool IDs here
const tokens = [
    {
        ca: "",
        poolId: ""
    },
];

async function getPrice(ca, poolId) {
    try {
        const url = `https://api.coinvera.io/api/v1/price?x-api-key=${x_api_key}&ca=${ca}&poolId=${poolId}`;
        const response = await axios.get(url);
        return { ca, poolId, ...response.data };
    } catch (err) {
        return { ca, poolId, error: err.message };
    }
}

async function getPricesForAllTokens() {
    const results = await Promise.all(tokens.map(token => getPrice(token.ca, token.poolId)));
    results.forEach(res => {
        if (res.error) {
            console.log(`Error for CA: ${res.ca}, Pool: ${res.poolId}: ${res.error}`);
        } else {
            console.log(`Token: ${res.ca}, Pool: ${res.poolId}`);
            console.log(res);
            console.log('-------------------------');
        }
    });
}

getPricesForAllTokens();
```

{% endtab %}

{% tab title="Pythong" %}

```python
import requests
import asyncio
import aiohttp
import json

x_api_key = ""

# Add your token addresses and pool IDs here
tokens = [
    {
        "ca": "",
        "poolId": ""
    },
]

async def get_price(session, ca, pool_id):
    try:
        url = f"https://api.coinvera.io/api/v1/price?x-api-key={x_api_key}&ca={ca}&poolId={pool_id}"
        async with session.get(url) as response:
            data = await response.json()
            return {"ca": ca, "poolId": pool_id, **data}
    except Exception as err:
        return {"ca": ca, "poolId": pool_id, "error": str(err)}

async def get_prices_for_all_tokens():
    async with aiohttp.ClientSession() as session:
        tasks = [get_price(session, token["ca"], token["poolId"]) for token in tokens]
        results = await asyncio.gather(*tasks)
        
        for res in results:
            if "error" in res:
                print(f"Error for CA: {res['ca']}, Pool: {res['poolId']}: {res['error']}")
            else:
                print(f"Token: {res['ca']}, Pool: {res['poolId']}")
                print(json.dumps(res, indent=2))
                print("-------------------------")

# Run the async function
asyncio.run(get_prices_for_all_tokens())
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"sync"
)

const xAPIKey = ""

type Token struct {
	CA     string `json:"ca"`
	PoolID string `json:"poolId"`
}

type PriceResult struct {
	CA     string      `json:"ca"`
	PoolID string      `json:"poolId"`
	Data   interface{} `json:"data,omitempty"`
	Error  string      `json:"error,omitempty"`
}

var tokens = []Token{
	{
		CA:     "",
		PoolID: "",
	},
}

func getPrice(token Token, wg *sync.WaitGroup, results chan<- PriceResult) {
	defer wg.Done()

	url := fmt.Sprintf("https://api.coinvera.io/api/v1/price?x-api-key=%s&ca=%s&poolId=%s", 
		xAPIKey, token.CA, token.PoolID)

	resp, err := http.Get(url)
	if err != nil {
		results <- PriceResult{
			CA:     token.CA,
			PoolID: token.PoolID,
			Error:  err.Error(),
		}
		return
	}
	defer resp.Body.Close()

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		results <- PriceResult{
			CA:     token.CA,
			PoolID: token.PoolID,
			Error:  err.Error(),
		}
		return
	}

	var data interface{}
	if err := json.Unmarshal(body, &data); err != nil {
		results <- PriceResult{
			CA:     token.CA,
			PoolID: token.PoolID,
			Error:  err.Error(),
		}
		return
	}

	results <- PriceResult{
		CA:     token.CA,
		PoolID: token.PoolID,
		Data:   data,
	}
}

func getPricesForAllTokens() {
	var wg sync.WaitGroup
	results := make(chan PriceResult, len(tokens))

	for _, token := range tokens {
		wg.Add(1)
		go getPrice(token, &wg, results)
	}

	go func() {
		wg.Wait()
		close(results)
	}()

	for result := range results {
		if result.Error != "" {
			fmt.Printf("Error for CA: %s, Pool: %s: %s\n", result.CA, result.PoolID, result.Error)
		} else {
			fmt.Printf("Token: %s, Pool: %s\n", result.CA, result.PoolID)
			jsonData, _ := json.MarshalIndent(result.Data, "", "  ")
			fmt.Println(string(jsonData))
			fmt.Println("-------------------------")
		}
	}
}

func main() {
	getPricesForAllTokens()
}
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  ca: '53JxiSEdahWu8FXnkeUbpoS2o2wXumc8ThzviBX7pump',
  poolId: '24hgLhdNLgPmJeUNAQMHJEBdbuZRBknRuaP1trTiBkD4',
  dex: 'pumpfun amm',
  liquidity: '33810.474998006444',
  priceInSol: '0.0000006679153339642684',
  priceInUsd: '0.00010054593656529703'
}
```

***

> **Tip:** Omitting `poolId` will trigger auto-detection across all pools for that token. Specify `poolId` when you need data from one exact pool.
