# Get Exchange Rates

Fetch the latest exchange-rate records for a requested currency pair, with optional pagination over the returned rate history.

## API Endpoint

```
GET `/api/v1/exchange-rate/fetch`
```

## Authorization

### BearerAuth

AuthorizationBearer <token>

In: `header`

## Query Parameters

- **from_currency** `string`
  - 3-letter source currency code
  - Length `3 <= length <= 3`

- **to_currency** `string`
  - 3-letter destination currency code
  - Length `3 <= length <= 3`

- **page** `integer` (optional)
  - Pagination page number
  - Range `1 <= value`

- **limit** `integer` (optional)
  - Number of records per page
  - Range `1 <= value <= 100`

## Response Body

### 200  application/json

### 401  application/json

### 422  application/json

### 500  application/json

## Example cURL Request

```bash
curl -X GET "https://atlas.tryduplo.com/api/v1/exchange-rate/fetch?from_currency=NGN&to_currency=KES&page=1&limit=10" \  
-H "Authorization: Bearer "
```

## Sample Responses

### Successful Response

```json
{
  "requestId": "3a6538fd-03f0-4b05-ba41-5d44769dd014",
  "requestTimestamp": "2026-02-20 10:15:30.123",
  "message": "Exchange rate retrieved successfully.",
  "statusCode": 200,
  "data": {
    "id": "b3a2e3ac-2744-4fb8-8f5f-49555f1637e1",
    "fromCurrency": "NGN",
    "toCurrency": "USD",
    "currentRate": 2046.77,
    "previousRate": 2046.77,
    "status": "active",
    "createdAt": "2026-02-20 10:15:30.123",
    "updatedAt": "2026-02-20 10:15:30.123"
  }
}
```

### Unauthenticated Response

```json
{
  "requestId": "f006ad7b-096c-4254-8c7e-2d23a55b0b0e",
  "requestTimestamp": "2026-02-20 10:15:30.123",
  "message": "Unauthenticated.",
  "statusCode": 401
}
```

### Invalid Data Response

```json
{
  "requestId": "f006ad7b-096c-4254-8c7e-2d23a55b0b0e",
  "requestTimestamp": "2026-02-20 10:15:30.123",
  "message": "The given data was invalid.",
  "errors": {
    "from_currency": [
      "The from currency field is required."
    ]
  },
  "statusCode": 422
}
```

### Server Error Response

```json
{
  "requestId": "f006ad7b-096c-4254-8c7e-2d23a55b0b0e",
  "requestTimestamp": "2026-02-20 10:15:30.123",
  "message": "An error occurred while processing your request.",
  "statusCode": 500
}
```

# Feedback

How is this guide?

Good | Bad

Last updated on 5/27/2026
