# 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>
