# Using the public API

## Getting a list of available exchanges

<mark style="color:blue;">`GET`</mark> `https://api.rates.cpay.world/ex/api/exchanges/list`

This endpoint allows you to get a list of all available exchanges, the Ids of which should be used in other requests.

#### Query Parameters

| Name   | Type   | Description                                       |
| ------ | ------ | ------------------------------------------------- |
| search | String | Search by exchange name                           |
| order  | String | Available values : ASC, DESC. Default value : ASC |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "data": {
    "page": 0,
    "pages": 0,
    "countItems": 0,
    "entities": [
      {
        "id": 0,
        "name": "string",
        "slug": "string",
        "isActive": true,
        "firstHistoricalData": "string",
        "lastHistoricalData": "string"
      }
    ]
  }
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    "status": "fail",
    "data": {
        "message": "Unauthorized"
    }
}
```

{% endtab %}
{% endtabs %}

## Getting cryptocurrency pairs on the selected exchange

<mark style="color:blue;">`GET`</mark> `https://api.rates.cpay.world/ex/api/exchanges/pairs`

#### Query Parameters

| Name                                         | Type   | Description                                                                                             |
| -------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------- |
| exchangeId<mark style="color:red;">\*</mark> | String | This parameter is the exchange Id that we get in the response to the GET /api​/exchanges​/list endpoint |
| search                                       | String | Search by crypto pair                                                                                   |
| order                                        | String | Available values : ASC, DESC. Default value : ASC                                                       |

#### Headers

| Name                                                 | Type   | Description                                                                                         |
| ---------------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------- |
| x-exchange-api-key<mark style="color:red;">\*</mark> | String | We get the value of this parameter in the API Key block after log in to <https://rates.cpay.world/> |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "data": {
    "page": 0,
    "pages": 0,
    "countItems": 0,
    "entities": [
      {
        "id": 0,
        "symbol": "string",
        "baseAsset": "string",
        "quoteAsset": "string",
        "price": 0,
        "volumeBaseAsset": 0,
        "volumeQuoteAsset": 0,
        "firstHistoricalData": "string",
        "lastHistoricalData": "string"
      }
    ]
  }
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    "status": "fail",
    "data": {
        "message": "Unauthorized"
    }
}
```

{% endtab %}

{% tab title="404: Not Found " %}

```javascript
{
    "status": "fail",
    "data": {
        "message": "Exchange not found."
    }
}
```

{% endtab %}
{% endtabs %}

## Cryptocurrency conversion

<mark style="color:blue;">`GET`</mark> `https://api.rates.cpay.world/ex/api/exchanges/convert`

This endpoint allows you to convert cryptocurrency to cryptocurrency, fiat currency to cryptocurrency, cryptocurrency to fiat currency, and fiat currency to fiat currency.

#### Query Parameters

| Name                                         | Type   | Description                                                                                             |
| -------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------- |
| from<mark style="color:red;">\*</mark>       | String | Parameter containing which currency the conversion is being performed from                              |
| to<mark style="color:red;">\*</mark>         | String | Parameter containing which currency the conversion is being performed to                                |
| exchangeId<mark style="color:red;">\*</mark> | String | This parameter is the exchange Id that we get in the response to the GET /api​/exchanges​/list endpoint |

#### Headers

| Name               | Type   | Description                                                                                         |
| ------------------ | ------ | --------------------------------------------------------------------------------------------------- |
| x-exchange-api-key | String | We get the value of this parameter in the API Key block after log in to <https://rates.cpay.world/> |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "data": {
    "price": 0
  }
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    "status": "fail",
    "data": {
        "message": "Pair not support."
    }
}
```

{% endtab %}

{% tab title="401 " %}

```javascript
{
    "status": "fail",
    "data": {
        "message": "Unauthorized"
    }
}
```

{% endtab %}
{% endtabs %}

## History of cryptocurrency pairs rates

<mark style="color:blue;">`GET`</mark> `https://api.rates.cpay.world/ex/api/exchanges/history`

This endpoint returns the exchange rate history for the selected pair

#### Query Parameters

| Name                                         | Type   | Description                                                                                                                                                                                   |
| -------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| symbol<mark style="color:red;">\*</mark>     | String | This parameter contains a crypto pair, the list of which can be obtained in the server response via the GET /api​/exchanges​/pairs endpoint                                                   |
| from<mark style="color:red;">\*</mark>       | String | This parameter contains the date and time from which the course history should be returned. *Example* : 2021-03-01 14:12:10                                                                   |
| to<mark style="color:red;">\*</mark>         | String | This parameter contains the date and time to which the course history should be returned. *Example* : 2021-03-01 14:12:10                                                                     |
| interval<mark style="color:red;">\*</mark>   | String | This parameter contains the interval with which you want to return the exchange rate history for the selected pair. Available values : hourly, daily, weekly, monthly. Default value: hourly. |
| exchangeId<mark style="color:red;">\*</mark> | String | This parameter is the exchange Id that we get in the response to the GET /api​/exchanges​/list endpoint                                                                                       |

#### Headers

| Name                                                 | Type   | Description                                                                                         |
| ---------------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------- |
| x-exchange-api-key<mark style="color:red;">\*</mark> | String | We get the value of this parameter in the API Key block after log in to <https://rates.cpay.world/> |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "data": [
    {
      "symbol": "string",
      "baseAsset": "string",
      "quoteAsset": "string",
      "timestamp": "string",
      "price": 0,
      "volumeBaseAsset": 0,
      "volumeQuoteAsset": 0
    }
  ]
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    "status": "fail",
    "data": {
        "message": "Unauthorized"
    }
}
```

{% endtab %}

{% tab title="404: Not Found " %}

```javascript
{
    "status": "fail",
    "data": {
        "message": "Exchange not found."
    }
}
```

{% endtab %}
{% endtabs %}

## List of cryptocurrencies with price, marketCap and etc..

<mark style="color:blue;">`GET`</mark> `https://api.rates.cpay.world/ex/api/public/assets/list`

#### Query Parameters

| Name   | Type   | Description                                       |
| ------ | ------ | ------------------------------------------------- |
| search | String | Search by cryptocurrency symbol                   |
| order  | String | Available values : ASC, DESC. Default value : ASC |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  "data": {
    "page": 0,
    "pages": 0,
    "countItems": 0,
    "entities": [
      {
        "id": 0,
        "symbol": "string",
        "baseAsset": "string",
        "quoteAsset": "string",
        "price": 0,
        "volumeBaseAsset": 0,
        "volumeQuoteAsset": 0,
        "marketCap": 0,
        "circulatingSupply": 0,
        "change24H": 0,
        "change24HPercent": 0,
        "history7D": [
          {
            "symbol": "string",
            "baseAsset": "string",
            "quoteAsset": "string",
            "timestamp": "string",
            "price": 0,
            "volumeBaseAsset": 0,
            "volumeQuoteAsset": 0
          }
        ]
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}


---

# 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://cpay-2.gitbook.io/cpay-coinprice-api-documentation/public-api/using-the-public-api.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.
