# Auto-detect an operator

With the `/operators/auto-detect/phone/{phone}/countries/{iso}` endpoint, a user can retrieve the operator details of a mobile number and the ISO code of the country where the mobile number is registered

## Auto-detect operator

<mark style="color:blue;">`GET`</mark> `https://topups.reloadly.com/operators/auto-detect/phone/{phone}/countries/{countryisocode}`

#### Path Parameters

| Name                                             | Type   | Description                                                       |
| ------------------------------------------------ | ------ | ----------------------------------------------------------------- |
| countryIsoCode<mark style="color:red;">\*</mark> | string | The ISO code of the country where the mobile number is registered |
| phone<mark style="color:red;">\*</mark>          | string | The mobile number whose operator is to be auto-detected           |

#### Query Parameters

| Name                 | Type    | Description                                                                               |
| -------------------- | ------- | ----------------------------------------------------------------------------------------- |
| suggested AmountsMap | boolean | Indicates if the `suggestedAmountsMap` field should be returned. Default value is `false` |
| suggested Amounts    | boolean | Indicates if the `suggestedAmounts` field should be returned. Default value is `false`    |

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

{% tabs %}
{% tab title="200 This response is gotten when a successful request is made and the details of a mobile number's operator are retrieved" %}
{% tabs %}
{% tab title="JSON" %}

```bash
{
  "operatorId":88,
  "name":"Movistar Colombia",
  "bundle":false,
  "data":false,
  "pin":false,
  "supportsLocalAmounts":false,
  "denominationType":"RANGE",
  "senderCurrencyCode":"USD",
  "senderCurrencySymbol":"$",
  "destinationCurrencyCode":"COP",
  "destinationCurrencySymbol":"$",
  "commission":4.42,
  "internationalDiscount":4.42,
  "localDiscount":0.00,
  "mostPopularAmount":null,
  "minAmount":5.00,
  "maxAmount":50,
  "localMinAmount":null,
  "localMaxAmount":null,
  "country":{
    "isoName":"CO",
    "name":"Colombia"
  },
  "fx":{
    "rate":2192.1867,
    "currencyCode":"COP"
  },
  "logoUrls":[
    "https://s3.amazonaws.com/rld-operator/3f4a8bcd3268-size-1.png",
    "https://s3.amazonaws.com/rld-operator/3f4a8bcd3268-size-2.png",
    "https://s3.amazonaws.com/rld-operator/3f4a8bcd3268-size-3.png"
  ],
  "fixedAmounts":[
    
  ],
  "fixedAmountsDescriptions":[
    
  ],
  "localFixedAmounts":[
    
  ],
  "localFixedAmountsDescriptions":[
    
  ],
  "suggestedAmounts":[
    7,
    10,
    15,
    20,
    25,
    30,
    35,
    40,
    45,
    50,
    55,
    60,
    65
  ],
  "suggestedAmountsMap":{
    "7":19482.51,
    "10":27832.16,
    "15":41748.23,
    "20":55664.31,
    "25":69580.39,
    "30":83496.46,
    "35":97412.54,
    "40":111328.61,
    "45":125244.69,
    "50":139160.77,
    "55":153076.84,
    "60":166992.92,
    "65":180909.00
  },
  "promotions":[
    
  ]
}
```

{% 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-12 08:06:03",
  "message":"Full authentication is required to access this resource",
  "path":"",
  "errorCode":"INVALID_TOKEN",
  "infoLink":null,
  "details":[
    
  ]
}
```

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

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

```bash
{
  "timestamp":"2021-05-17T14:40:02.376+0000",
  "status":404,
  "error":"Not Found",
  "message":"No message available",
  "path":"/operators/auto-detect/phon/03238482221/countries/PK
```

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

{% hint style="info" %}
Reloadly has an open-source library used to format, parse, and validate the authenticity of an international phone number. You can check it out [here on GitHub](https://github.com/google/libphonenumber).
{% endhint %}

{% hint style="info" %}
Do note that due to the regional differences across Indian operators, the Auto-detect endpoint is a **PAID** service for mobile numbers registered in **India**. This service costs **0.0013 USD** per API call involving mobile numbers registered in **India** only. \
\
If you have any questions, you can always reach out to us via  [our developer community](https://join.slack.com/t/reloadly-developers/shared_invite/zt-qflikche-fwiFA5Sxtst2mXzvJBPO3w)
{% endhint %}

###

### Request samples

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

```bash
curl --location --request GET 'https://topups.reloadly.com/operators/auto-detect/phone/03238482221/countries/PK?suggestedAmountsMap=true&SuggestedAmounts=true' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN_HERE' \
--header 'Accept: application/com.reloadly.topups-v1+json'
```

{% 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 message = new HttpRequestMessage(HttpMethod.Get, "https://topups.reloadly.com/operators/auto-detect/phone/03238482221/countries/PK?suggestedAmountsMap=true&SuggestedAmounts=true");

      message.Headers.TryAddWithoutValidation("Authorization", "Bearer YOUR_ACCESS_TOKEN_HERE");
      message.Headers.TryAddWithoutValidation("Accept", "application/com.reloadly.topups-v1+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"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://topups.reloadly.com/operators/auto-detect/phone/03238482221/countries/PK?suggestedAmountsMap=true&SuggestedAmounts=true"
  method := "GET"

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

  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")

  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();
Request request = new Request.Builder()
  .url("https://topups.reloadly.com/operators/auto-detect/phone/03238482221/countries/PK?suggestedAmountsMap=true&SuggestedAmounts=true")
  .method("GET", null)
  .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN_HERE")
  .addHeader("Accept", "application/com.reloadly.topups-v1+json")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="Node JS" %}

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://topups.reloadly.com/operators/auto-detect/phone/03238482221/countries/PK?suggestedAmountsMap=true&SuggestedAmounts=true',
  'headers': {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN_HERE',
    'Accept': 'application/com.reloadly.topups-v1+json'
  }
};
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/auto-detect/phone/03238482221/countries/PK?suggestedAmountsMap=true&SuggestedAmounts=true',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer YOUR_ACCESS_TOKEN_HERE',
    'Accept: application/com.reloadly.topups-v1+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/auto-detect/phone/03238482221/countries/PK?suggestedAmountsMap=true&SuggestedAmounts=true"

payload={}
headers = {
  'Authorization': 'Bearer YOUR_ACCESS_TOKEN_HERE',
  'Accept': 'application/com.reloadly.topups-v1+json'
}

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

print(response.text)
```

{% endtab %}
{% endtabs %}

###

### Response parameters

| Parameter                                                            | Type    | Description                                                                                                               |
| -------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- |
| `id/operatorId`                                                      | integer | This indicates the operator's ID                                                                                          |
| `name`                                                               | string  | The operator's name                                                                                                       |
| `bundle`                                                             | boolean | Indicates if the operator has any existing bundle plans                                                                   |
| `data`                                                               | boolean | Indicates if the operator has any existing data plans                                                                     |
| `pin`                                                                | boolean | Indicates if the operator supports PIN transactions                                                                       |
| <p><code>supportsLocal</code></p><p><code>Amounts</code></p>         | boolean | Indicates if the operator can make top-ups in local amounts                                                               |
| `denominationType`                                                   | string  | Indicates if the operator makes top-ups through a fixed amount or a range of amounts. Options include `FIXED` and `RANGE` |
| `senderCurrencyCode`                                                 | string  | Indicates the currency code of the account where the top-up is being made from                                            |
| <p><code>senderCurrency</code></p><p><code>Symbol</code></p>         | string  | Indicates the currency symbol of the account where the top-up is being made from                                          |
| <p><code>destination</code></p><p><code>CurrencyCode</code></p>      | string  | Indicates the currency code of the mobile number where the top-up is being sent to                                        |
| <p><code>destination</code></p><p><code>CurrencySymbol</code></p>    | string  | Indicates the currency symbol of the mobile number where the top-up is being sent to                                      |
| `commission`                                                         | integer | Indicates if the operator offers a commission or discount                                                                 |
| <p><code>international</code></p><p><code>Discount</code></p>        | integer | Indicates if the operator offers a discount for top-ups made to foreign numbers                                           |
| `localDiscount`                                                      | integer | Indicates if the operator offers a discount for top-ups made to local numbers                                             |
| `mostPopularAmount`                                                  | integer | Indicates the amount that is often used to make a top-up                                                                  |
| <p><code>mostPopular</code></p><p><code>LocalAmount</code></p>       | integer | Indicates the amount that is often used to make a top-up locally                                                          |
| `minAmount`                                                          | integer | Indicates the minimum amount that can be used to make a top-up                                                            |
| `maxAmount`                                                          | integer | Indicates the maximum amount that can be used to make a top-up                                                            |
| `localMinAmount`                                                     | integer | Indicates the minimum amount that can be used to make a top-up locally                                                    |
| `localMaxAmount`                                                     | integer | Indicates the maximum amount that can be used to make a top-up locally                                                    |
| `isoName`                                                            | string  | Indicates the country's ISO code                                                                                          |
| `name`                                                               | string  | Indicates the country's name                                                                                              |
| `rate`                                                               | integer | Indicates the FX rate at which the top-up will be made                                                                    |
| `currencyCode`                                                       | string  | Indicates the code of the currency at which the top-up will be made                                                       |
| `logoURLs`                                                           | string  | These are links to SVG images of the operator's logos                                                                     |
| `fixedAmounts`                                                       | integer | Indicates the fixed amounts that a top-up can be made in with the operator                                                |
| <p><code>fixedAmounts</code></p><p><code>Description</code></p>      | string  | Indicates the descriptions for the operator's fixed amounts                                                               |
| `localFixedAmounts`                                                  | integer | Indicates the local fixed amounts that a top-up can be made in with the operator                                          |
| <p><code>localFixedAmounts</code></p><p><code>Description</code></p> | string  | Indicates the descriptions for the operator's local fixed amounts                                                         |
| `suggestedAmounts`                                                   | integer | Indicates the suggested amounts that can be used to make a top-up with the operator                                       |
| <p><code>suggestedAmounts</code></p><p><code>Map</code></p>          | string  | Indicates the suggested amounts that can be mapped through                                                                |
| `promotions`                                                         | string  | Indicates the promotions currently offered by the operator                                                                |
