# Get Token Price

#### Authentication

1. **Query Parameter**\
   Append your API key to the URL:

   ```
   ?x-api-key=<YOUR_API_KEY>
   ```
2. **HTTP Header**\
   Include the header in your request:

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

***

#### Single-Token Price Requests

Replace `<TOKEN_MINT>` and `<YOUR_API_KEY>` with your token’s mint address and your CoinVera API key.

| Endpoint                      | URL Example                                                                            |
| ----------------------------- | -------------------------------------------------------------------------------------- |
| **Auto-Detect (Low-Latency)** | `GET https://api.coinvera.io/api/v1/price?ca=<TOKEN_MINT>&x-api-key=<YOUR_API_KEY>`    |
| **PumpFun**                   | `GET https://api.coinvera.io/api/v1/pumpfun?ca=<TOKEN_MINT>&x-api-key=<YOUR_API_KEY>`  |
| **Meteora**                   | `GET https://api.coinvera.io/api/v1/meteora?ca=<TOKEN_MINT>&x-api-key=<YOUR_API_KEY>`  |
| **Raydium (All Pools)**       | `GET https://api.coinvera.io/api/v1/raydium?ca=<TOKEN_MINT>&x-api-key=<YOUR_API_KEY>`  |
| **Moonshot**                  | `GET https://api.coinvera.io/api/v1/moonshot?ca=<TOKEN_MINT>&x-api-key=<YOUR_API_KEY>` |

**Using HTTP Headers**

```http
GET /api/v1/price?ca=<TOKEN_MINT> HTTP/1.1
Host: api.coinvera.io
x-api-key: <YOUR_API_KEY>
```

*(Swap `/price` for `/pumpfun`, `/raydium`, etc., as needed.)*

***

#### Multi-Token Price Requests

Fetch prices for multiple tokens in one call by passing a comma-separated list of mint addresses:

```http
GET https://api.coinvera.io/api/v1/price?ca=<MINT1>,<MINT2>,<MINT3>&x-api-key=<YOUR_API_KEY>
```

***

**Code Examples**

Fetch a single token’s price per request—see the code examples below.

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

```javascript
const fetch = require('node-fetch');

const x_api_key = "<YOUR-API-KEY>"; // <-- Replace with your actual API key

const tokenAddresses = [
    "<MINT-ADDRESS>"
];

async function getPrice(ca) {
    try {
        const url = `https://api.coinvera.io/api/v1/price?ca=${ca}`;
        const result = await fetch(url, {
            headers: {
                "Content-Type": "application/json",
                "x-api-key": x_api_key,
            }
        });
        const data = await result.json();
        return { ca, ...data };
    } catch (err) {
        return { ca, error: err.message };
    }
}

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

getPricesForAllTokens();

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

x_api_key = "<YOUR-API-KEY>"  # Replace with your actual API key

token_addresses = [
    "<MINT-ADDRESS>"
]

def get_price(ca):
    url = f"https://api.coinvera.io/api/v1/price?ca={ca}"
    headers = {
        "Content-Type": "application/json",
        "x-api-key": x_api_key
    }
    try:
        response = requests.get(url, headers=headers)
        response.raise_for_status()  # raises HTTPError for bad responses
        data = response.json()
        return {'ca': ca, **data}
    except requests.exceptions.RequestException as err:
        return {'ca': ca, 'error': str(err)}

def get_prices_for_all_tokens():
    results = [get_price(ca) for ca in token_addresses]
    for res in results:
        if 'error' in res:
            print(f"Error for {res['ca']}: {res['error']}")
        else:
            print(f"Token: {res['ca']}")
            print(res)
            print('-------------------------')

if __name__ == "__main__":
    get_prices_for_all_tokens()

```

{% endtab %}

{% tab title="Go" %}

```go
package main

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

const xAPIKey = "<YOUR-API-KEY>" // Replace with your actual API key

var tokenAddresses = []string{
    "<MINT-ADDRESS>",
}

type APIResponse struct {
    CA     string                 `json:"ca"`
    Data   map[string]interface{} `json:"data,omitempty"`
    Error  string                 `json:"error,omitempty"`
}

func getPrice(ca string) APIResponse {
    url := fmt.Sprintf("https://api.coinvera.io/api/v1/price?ca=%s", ca)

    req, err := http.NewRequest("GET", url, nil)
    if err != nil {
        return APIResponse{CA: ca, Error: err.Error()}
    }

    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("x-api-key", xAPIKey)

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        return APIResponse{CA: ca, Error: err.Error()}
    }
    defer resp.Body.Close()

    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        return APIResponse{CA: ca, Error: err.Error()}
    }

    var data map[string]interface{}
    if err := json.Unmarshal(body, &data); err != nil {
        return APIResponse{CA: ca, Error: err.Error()}
    }

    return APIResponse{CA: ca, Data: data}
}

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

    for _, ca := range tokenAddresses {
        wg.Add(1)
        go func(ca string) {
            defer wg.Done()
            results <- getPrice(ca)
        }(ca)
    }

    wg.Wait()
    close(results)

    for res := range results {
        if res.Error != "" {
            fmt.Printf("Error for %s: %s\n", res.CA, res.Error)
        } else {
            fmt.Printf("Token: %s\n", res.CA)
            fmt.Printf("%v\n", res.Data)
            fmt.Println("-------------------------")
        }
    }
}

func main() {
    getPricesForAllTokens()
}

```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  ca: '',
  dex: '',
  priceInSol: ,
  priceInUsd: ,
  marketCap: 
}
```

Fetch multiple tokens’ prices in a single request—example below.

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

```javascript
const fetch = require('node-fetch');

const x_api_key = ""; // <-- Replace with your actual API key

const tokenAddresses = [
    "mint-1",
    "mint-2"
];

async function getPrice(ca) {
    try {
        const url = `https://api.coinvera.io/api/v1/price?ca=${ca}`;
        const result = await fetch(url, {
            headers: {
                "Content-Type": "application/json",
                "x-api-key": x_api_key,
            }
        });
        const data = await result.json();
        return { ca, ...data };
    } catch (err) {
        return { ca, error: err.message };
    }
}

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

getPricesForAllTokens();

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

x_api_key = "<YOUR-API-KEY>"  # Replace with your actual API key

token_addresses = [
    "<MINT-ADDRESS-1>",
    "<MINT-ADDRESS-2>"
]

def get_price(ca):
    url = f"https://api.coinvera.io/api/v1/price?ca={ca}"
    headers = {
        "Content-Type": "application/json",
        "x-api-key": x_api_key
    }
    try:
        response = requests.get(url, headers=headers)
        response.raise_for_status()  # raises HTTPError for bad responses
        data = response.json()
        return {'ca': ca, **data}
    except requests.exceptions.RequestException as err:
        return {'ca': ca, 'error': str(err)}

def get_prices_for_all_tokens():
    results = [get_price(ca) for ca in token_addresses]
    for res in results:
        if 'error' in res:
            print(f"Error for {res['ca']}: {res['error']}")
        else:
            print(f"Token: {res['ca']}")
            print(res)
            print('-------------------------')

if __name__ == "__main__":
    get_prices_for_all_tokens()

```

{% endtab %}

{% tab title="Go" %}

```go
package main

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

const xAPIKey = "<YOUR-API-KEY>" // Replace with your actual API key

var tokenAddresses = []string{
    "<MINT-ADDRESS-1>",
    "<MINT-ADDRESS-2>"
}

type APIResponse struct {
    CA     string                 `json:"ca"`
    Data   map[string]interface{} `json:"data,omitempty"`
    Error  string                 `json:"error,omitempty"`
}

func getPrice(ca string) APIResponse {
    url := fmt.Sprintf("https://api.coinvera.io/api/v1/price?ca=%s", ca)

    req, err := http.NewRequest("GET", url, nil)
    if err != nil {
        return APIResponse{CA: ca, Error: err.Error()}
    }

    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("x-api-key", xAPIKey)

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        return APIResponse{CA: ca, Error: err.Error()}
    }
    defer resp.Body.Close()

    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        return APIResponse{CA: ca, Error: err.Error()}
    }

    var data map[string]interface{}
    if err := json.Unmarshal(body, &data); err != nil {
        return APIResponse{CA: ca, Error: err.Error()}
    }

    return APIResponse{CA: ca, Data: data}
}

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

    for _, ca := range tokenAddresses {
        wg.Add(1)
        go func(ca string) {
            defer wg.Done()
            results <- getPrice(ca)
        }(ca)
    }

    wg.Wait()
    close(results)

    for res := range results {
        if res.Error != "" {
            fmt.Printf("Error for %s: %s\n", res.CA, res.Error)
        } else {
            fmt.Printf("Token: %s\n", res.CA)
            fmt.Printf("%v\n", res.Data)
            fmt.Println("-------------------------")
        }
    }
}

func main() {
    getPricesForAllTokens()
}

```

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    ca: '',
    dex: '',
    priceInSol: ,
    priceInUsd: ,
    marketCap: ,
    success: true
  },
  {
    ca: '',
    dex: '',
    priceInSol: ,
    priceInUsd: ,
    marketCap: ,
    success: true
  }
]
```

> **Tip:** Experiment with different endpoints to find the lowest-latency feed for your use case. If you have questions, see our API Reference or reach out on our community channels.


---

# 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.coinvera.io/integration/solana/get-token-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.
