> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ngnmarket.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Forex Rates

> Fetch the current USD/NGN rate and 30-day exchange rate history.

This example fetches the latest NGN exchange rates against all supported currencies, then drills into the USD/NGN pair for a 30-day history suitable for charting.

**Endpoints used:**

* `GET /forex/current` (Free plan)
* `GET /forex/history` (Starter plan)

## Fetch current rates

Returns live NGN rates against all supported currencies in a single call.

<CodeGroup>
  ```bash curl theme={null}
  curl "https://api.ngnmarket.com/v1/forex/current" \
    -H "Authorization: Bearer ngm_live_YOUR_KEY"
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch(
    'https://api.ngnmarket.com/v1/forex/current',
    { headers: { Authorization: 'Bearer ngm_live_YOUR_KEY' } }
  );
  const { data } = await res.json();
  // data.rates → { USD: 1580.25, GBP: 2012.40, EUR: 1720.60, ... }
  ```

  ```python Python theme={null}
  import requests

  res = requests.get(
      'https://api.ngnmarket.com/v1/forex/current',
      headers={'Authorization': 'Bearer ngm_live_YOUR_KEY'},
  )
  rates = res.json()['data']['rates']
  usd_rate = rates['USD']
  ```
</CodeGroup>

### Sample response

```json theme={null}
{
  "success": true,
  "data": {
    "base": "NGN",
    "updated_at": "2026-04-17T16:00:00.000Z",
    "rates": {
      "USD": 1580.25,
      "GBP": 2012.40,
      "EUR": 1720.60,
      "CAD": 1148.30,
      "AUD": 1022.15,
      "GHS": 98.40,
      "ZAR": 84.70,
      "CNY": 218.90,
      "JPY": 10.52,
      "SAR": 421.10
    }
  },
  "meta": {
    "plan": "free",
    "calls_used": 5,
    "calls_remaining": 9995,
    "reset_at": "2026-05-01T00:00:00.000Z"
  }
}
```

## Fetch 30-day USD/NGN history

Useful for rendering a rate trend chart or calculating how much the naira has moved against the dollar.

<CodeGroup>
  ```bash curl theme={null}
  curl "https://api.ngnmarket.com/v1/forex/history?source=USD&target=NGN&period=30d&format=simple" \
    -H "Authorization: Bearer ngm_live_YOUR_KEY"
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch(
    'https://api.ngnmarket.com/v1/forex/history?source=USD&target=NGN&period=30d&format=simple',
    { headers: { Authorization: 'Bearer ngm_live_YOUR_KEY' } }
  );
  const { data } = await res.json();
  // data.data → [{ date: "2026-04-17", rate: 1580.25 }, ...]
  ```

  ```python Python theme={null}
  res = requests.get(
      'https://api.ngnmarket.com/v1/forex/history',
      params={'source': 'USD', 'target': 'NGN', 'period': '30d', 'format': 'simple'},
      headers={'Authorization': 'Bearer ngm_live_YOUR_KEY'},
  )
  history = res.json()['data']['data']
  # [{'date': '2026-04-17', 'rate': 1580.25}, ...]
  ```
</CodeGroup>

### Sample response (trimmed)

```json theme={null}
{
  "success": true,
  "data": {
    "source": "USD",
    "target": "NGN",
    "period": "30d",
    "count": 30,
    "data": [
      { "date": "2026-04-17", "rate": 1580.25 },
      { "date": "2026-04-16", "rate": 1577.80 },
      { "date": "2026-04-15", "rate": 1582.10 }
    ]
  }
}
```

## Supported currencies

`USD` `EUR` `GBP` `CAD` `AUD` `GHS` `ZAR` `CNY` `JPY` `SAR` `NGN`

Pass `source` and `target` in any direction. For example, `source=NGN&target=USD` gives you the inverse rate.

<CardGroup cols={2}>
  <Card title="Current rates reference" icon="book" href="/api-reference/forex/current">
    `GET /forex/current` parameters
  </Card>

  <Card title="Rate history reference" icon="book" href="/api-reference/forex/history">
    `GET /forex/history` parameters
  </Card>
</CardGroup>
