> For the complete documentation index, see [llms.txt](https://raphaelugwu.gitbook.io/airtime/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://raphaelugwu.gitbook.io/airtime/fx-rates/fetch-fx-rate-by-operator-id.md).

# Fetch FX Rate by operator ID

The `/operators/fx-rate` endpoint allows you to fetch an operator's foreign exchange rate for international top-ups

## FX Rate

<mark style="color:green;">`POST`</mark> `https://topups.reloadly.com/operators/fx-rate`

#### Headers

| Name                                            | Type   | Description                                                             |
| ----------------------------------------------- | ------ | ----------------------------------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Your access token is required as a bearer token in the request's header |

#### Request Body

| Name                                         | Type    | Description                                                 |
| -------------------------------------------- | ------- | ----------------------------------------------------------- |
| operatorId<mark style="color:red;">\*</mark> | integer | The ID of the receiving mobile number's operator            |
| amount<mark style="color:red;">\*</mark>     | integer | The top-up amount being sent to the receiving mobile number |

{% tabs %}
{% tab title="200 This response is gotten when a successful request is made and an operator's foreign exchange rate is retrieved" %}
{% tabs %}
{% tab title="JSON" %}

```bash
{
  "id":174,
  "name":"Natcom Haiti",
  "fxRate":465.00,
  "currencyCode":"HTG"
}
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="401 This response is gotten when an incorrect or expired access token is used to make a request" %}
{% tabs %}
{% tab title="JSON" %}

```bash
{
    "timeStamp": "2021-05-11 22:34:35",
    "message": "Full authentication is required to access this resource",
    "path": "/operators/fx-rate",
    "errorCode": "INVALID_TOKEN",
    "infoLink": null,
    "details": []
}
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="404 This response is gotten when a request is made to an incorrect URL path" %}
{% tabs %}
{% tab title="JSON" %}

```bash
{
    "timestamp": "2021-05-11T23:46:00.418+0000",
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/operator/fx-rate"
}
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="500 This response is gotten when a request is made to an operator without an FX rate" %}
{% tabs %}
{% tab title="JSON" %}

```bash
{
    "timeStamp": "2021-05-11 23:43:04",
    "message": "Fx rate is currently not available for this operator, please try again later or contact support.",
    "path": "/operators/fx-rate",
    "errorCode": "FX_RATE_NOT_AVAILABLE",
    "infoLink": null,
    "details": []
}
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

###

### Request samples

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

```bash
curl --location --request POST 'https://topups.reloadly.com/operators/fx-rate' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN_HERE' \
--header 'Accept: application/com.reloadly.topups-v1+json' \
--header 'Content-Type: application/json' \
--data-raw '{
	"operatorId":"341",
	"amount":"10"
}'
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Threading.Tasks;
using System.Net.Http;
using System.Text;
using Newtonsoft.Json;

namespace WebAPIClient {
  class Program {

    static async Task Main(string[] args) {
      await ApiCall();
    }

    private static async Task ApiCall() {
      var json = JsonConvert.SerializeObject(new {
        operator_id = "1", 
        amount = "1" 
      });

      var message = new HttpRequestMessage(HttpMethod.Post, "https://topups.reloadly.com/operators/fx-rate");

      message.Headers.TryAddWithoutValidation("Authorization", "Bearer YOUR_ACCESS_TOKEN_HERE");
      message.Headers.TryAddWithoutValidation("Accept", "application/com.reloadly.topups-v1+json");
      message.Headers.TryAddWithoutValidation("Content-Type", "application/json");

      using
      var httpClient = new HttpClient();
      var response = await httpClient.SendAsync(message);
      var responseBody = await response.Content.ReadAsStringAsync();
      var result = JsonConvert.DeserializeObject < dynamic > (responseBody);

      Console.WriteLine(result);
    }

  }
}
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://topups.reloadly.com/operators/fx-rate"
  method := "POST"

  payload := strings.NewReader(`{
	"operatorId":"341",
	"amount":"10"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Bearer YOUR_ACCESS_TOKEN_HERE")
  req.Header.Add("Accept", "application/com.reloadly.topups-v1+json")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"operatorId\":\"341\",\n\t\"amount\":\"10\"\n}");
Request request = new Request.Builder()
  .url("https://topups.reloadly.com/operators/fx-rate")
  .method("POST", body)
  .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN_HERE")
  .addHeader("Accept", "application/com.reloadly.topups-v1+json")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Node JS" %}

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://topups.reloadly.com/operators/fx-rate',
  'headers': {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN_HERE',
    'Accept': 'application/com.reloadly.topups-v1+json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "operatorId": "341",
    "amount": "10"
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://topups.reloadly.com/operators/fx-rate',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
	"operatorId":"341",
	"amount":"10"
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer YOUR_ACCESS_TOKEN_HERE',
    'Accept: application/com.reloadly.topups-v1+json',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://topups.reloadly.com/operators/fx-rate"

payload = json.dumps({
  "operatorId": "341",
  "amount": "10"
})
headers = {
  'Authorization': 'Bearer YOUR_ACCESS_TOKEN_HERE',
  'Accept': 'application/com.reloadly.topups-v1+json',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}
{% endtabs %}

###

### Response parameters

| Parameter      | Type    | Description                                                                                                                                                                                                                                                                    |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `id`           | integer | Indicates the ID of the operator                                                                                                                                                                                                                                               |
| `name`         | string  | Indicates the operator's name                                                                                                                                                                                                                                                  |
| `fxRate`       | integer | Indicates the exchange rate of the operator's currency to your account's currency. For example, if your account is in Indian Rupees( INR ) and you are making a top-up to a number registered to  `Natcom Haiti`, the exchange rate returned will be 1.16 ( 1 INR = 1.16 HTG ) |
| `currencyCode` | string  | Indicates the currency symbol of the country where the operator is registered                                                                                                                                                                                                  |
