# Bank of Israel rate for a date

`GET /businesses/{bid}/fx-rate`

Requires the `documents` scope.

The שער יציג a foreign-currency document dated `date` is converted at when the draft carries no `fxRate` of its own: the last rate the Bank of Israel published on or before that day. Show it to your user before issue; pass `fxRate` on the draft to use a different one. `fx_rate_required` (422) when there is none to be had (a future date, the service down).

## Path parameters

| Name | Type | | Description |
|---|---|---|---|
| `bid` | string | **required** | Business id, from `POST /businesses`. |

## Query parameters

| Name | Type | | Description |
|---|---|---|---|
| `currency` | string | **required** |  One of: `USD`, `EUR`, `GBP`, `CHF`, `AUD`, `CAD`. |
| `date` | string |  | The document date. Defaults to today, Asia/Jerusalem. |

## Response

`200`: `{ "ok": true, … }`

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `fx` | object | **required** |  |
| `fx.currency` | string | **required** |  |
| `fx.date` | string | **required** | The date asked for. |
| `fx.rate` | number | **required** | ILS per 1 unit. |
| `fx.rateDate` | string | **required** | The publishing day the rate is from (≤ date). |
| `fx.source` | string |  |  One of: `boi`. |

Errors: `400`, `401`, `403`, `404`, `422`, `429`. Every failure answers `{ "error", "reason", "hint", "param", "doc_url", "retryable", "request_id" }`: branch on `reason`, and read `hint` for what to change (https://docs.billos.co.il/errors.md).

## Examples

### cURL

```bash
curl -X GET "$BASE/businesses/$BID/fx-rate?currency=&date=" \
  -H "X-Api-Key: $KEY"
```
### Node

```node
const res = await fetch(`${BASE}/businesses/${BID}/fx-rate`, {
  method: 'GET',
  headers: {
    'X-Api-Key': KEY,
  },
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
```
### Python

```python
import requests
res = requests.get(
    f"{BASE}/businesses/{BID}/fx-rate",
    headers={"X-Api-Key": KEY},
)
data = res.json()
```