> For the complete documentation index, see [llms.txt](https://cpay-2.gitbook.io/cpay-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cpay-2.gitbook.io/cpay-1/public-api/using-the-public-api-for-transaction-and-currency.md).

# Using the Public API for transaction and currency

### Fee estimate

## Endpoint POST /api/public/transaction/fee

<mark style="color:green;">`POST`</mark> `https://api.cpay.world/api/public/transaction/fee`

Endpoint, allows you to estimate transactions. You need to log in with the wallet in conjunction with the merchant.

#### Request Body

| Name                                     | Type    | Description                                                 |
| ---------------------------------------- | ------- | ----------------------------------------------------------- |
| to<mark style="color:red;">\*</mark>     | String  |                                                             |
| amount<mark style="color:red;">\*</mark> | Number  |                                                             |
| priority                                 | Boolean | Parameter for defining the high priority of the transaction |

{% tabs %}
{% tab title="200: OK Example for currency" %}

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

{% endtab %}

{% tab title="200: OK Example for token" %}

```javascript
{
  "data": {
    "fee": 0,
    "ethFee": 0
  }
}
```

{% endtab %}

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

```javascript
{
    "status": "fail",
    "data": {
        "message": [
            "amount must be a number conforming to the specified constraints",
            "priority must be a boolean value"
        ]
    }
}
```

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

### Merchant currency

## Endpoint GET /api/public/currency

<mark style="color:blue;">`GET`</mark> `https://api.cpay.world/api/public/currency`

The endpoint allows you to get all the currencies that the merchant supports. You need to log in to the merchant.

#### Query Parameters

| Name  | Type   | Description |
| ----- | ------ | ----------- |
| page  | Nubmer |             |
| limit | Number |             |

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

```javascript
{
  "data": {
    "page": 0,
    "pages": 0,
    "countItems": 0,
    "currencies": [
      {
        "_id": "string",
        "name": "string",
        "title": "string",
        "nodeType": "string",
        "currencyType": "string"
      }
    ]
  }
}
```

{% endtab %}

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

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

{% endtab %}
{% endtabs %}
