# Rate methods

## Rate object

<table><thead><tr><th width="232">Name</th><th width="106">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>left</code></td><td>string</td><td>The base currency.</td></tr><tr><td><code>right</code></td><td>string</td><td>The quote currency.</td></tr><tr><td><code>bid</code></td><td>string</td><td>The current bid price.</td></tr><tr><td><code>ask</code></td><td>string</td><td>The current ask price.</td></tr><tr><td><code>exp</code></td><td>number</td><td>The currency precision, that is the number of digits after the decimal separator, for the <code>bid</code> and <code>ask</code> fields.</td></tr><tr><td><code>created_at</code></td><td>string</td><td>The date and time when a rate was received.</td></tr><tr><td><code>expired_at</code></td><td>string</td><td>The date and time of rate expiration.</td></tr></tbody></table>

#### Rate object example

```json
{
  "type": "rate",
  "id": "0",
  "attributes": {
    "left": "ZRX",
    "right": "USDC",
    "bid": "0.381855018600000000",
    "ask": "0.389670322000000000",
    "exp": 18,
    "expired_at": "2024-02-28T09:45:48.314413Z",
    "created_at": "2024-02-28T09:40:48.314413Z"
  }
}
```

***

## Get rates

### Request

<mark style="color:green;">`GET`</mark> `[base]/rates/`

Rates can be filtered by the `left` and `right` parameters according to the [JSON API Specification](https://jsonapi.org/format/#query-parameters-families). For example, the response body will only contain the rates with the BTC base currency: `/rates?filter[left]=BTC`. You can specify more than one currency, for example, the response body will contain the rates with the BTC and USDT base currencies: `/rates?filter[left]=BTC,USDT`.

#### Request example

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

```sh
curl --request GET \
--url [base]/rates/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/vnd.api+json'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = '[base]/rates/'

headers = {
  'Authorization': 'Bearer <token>',
  'Content-Type': 'application/vnd.api+json',
}

requests.get(url, headers=headers)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
  $res = $client->get('[base]/rates/', [
    'headers' => [
      'Authorization' => 'Bearer <token>',
      'Content-Type' => 'application/vnd.api+json',
    ],
  ]);
echo $res->getBody();
} catch (RequestException $e) {}
```

{% endtab %}
{% endtabs %}

### Response

In case of success, the response body contains an array of [rate objects](#rate-object).

#### Response codes

<table><thead><tr><th width="134">HTTP code</th><th width="274">Application code</th><th width="170">Description</th><th>Suggested action</th></tr></thead><tbody><tr><td><mark style="color:green;"><code>200</code></mark></td><td>—</td><td>The request succeeded.</td><td>—</td></tr><tr><td><mark style="color:red;"><code>400</code></mark></td><td>—</td><td>bad request.</td><td>—</td></tr><tr><td><mark style="color:red;"><code>500</code></mark></td><td>—</td><td>Internal server error.</td><td>Try again later.</td></tr><tr><td><mark style="color:red;"><code>502</code></mark></td><td>—</td><td>Bad gateway.</td><td>Try again later.</td></tr><tr><td><mark style="color:red;"><code>503</code></mark></td><td>—</td><td>Service unavailable.</td><td>Try again later.</td></tr><tr><td><mark style="color:red;"><code>504</code></mark></td><td>—</td><td>Gateway timeout.</td><td>Try again later.</td></tr><tr><td><mark style="color:red;"><code>5xx</code></mark></td><td>—</td><td>Other server errors.</td><td>Try again later.</td></tr></tbody></table>


---

# 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.b2binpay.com/api-guide/rate-methods.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.
