# HLR API

DecisionTelecom allows you to send network requests to any mobile number around the world. This allows you to view which mobile phone number belongs to which operator in real time and see if the number is active.

**API Authorization -** Basic access key Base64.

Please contact your account manager for an API key.

## Send HLR

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

```
 https://web.it-decision.com/v1/api/hlr 
```

{% endtab %}
{% endtabs %}

**Request JSON:**

```json
{
    "phones":[380636151111,380631111112]
}
```

#### **Parameters:**

**Phones**: <mark style="color:red;">array</mark> - The list of phone numbers on which you want to make a network request. - Required.

#### **Response:**

Returns JSON string if the request was successful.

```json
[
 {
          "id": 2345234,
          "phone": 380631111111,
          "href": "https://web.it-decision.com/v1/api/hlr-status?id=380631111111",
          "status": "Accepted"
 },
 {
          "id": 2345235,
          "phone": 380631111112,
          "href": "https://web.it-decision.com/v1/api/hlr-status?id=380631111112",
          "status": "Accepted"
 }
]  
```

#### **Parameters:**

**Id** <mark style="color:red;">int</mark> - A unique random identifier generated by the DecisionTelecom platform. - Required.

**status** <mark style="color:red;">string</mark> – phone state.

**Possible values:** accepted, sent, absent, active, unknown, and failed.

## **Status HLR**

#### **Request example:**

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

```
//singl
https://web.it-decision.com/v1/api/hlr-status?id=2345234
//bullk
https://web.it-decision.com/v1/api/hlr-status?id=["1","2","3"]
```

{% endtab %}
{% endtabs %}

#### **Response Example JSON:**

```json
//singl
{
    "id": 2345234,
    "phone": 38061122121,
    "mcc": "255",
    "mnc": "06",
    "network": "Lifecell",
    "ported": false,
    "status": 0,
    "error": 0,
    "type": "mobile",
    "present": "yes",
    "status_message": "Success"
}
//bullk
[
    {
        "id": "1",
        "phone": 120111111111,
        "mcc": "310",
        "mnc": "012",
        "network": "Verizon Wireless:6006 - SVR/2",
        "ported": false,
        "status": 0,
        "present": "yes",
        "error": 0,
        "type": "mobile",
        "status_message": "Success"
    },
    {
        "id": "2",
        "phone": 12011111111,
        "mcc": "310",
        "mnc": "260",
        "network": "T-Mobile US-SVR-10X/2",
        "ported": true,
        "status": 0,
        "present": "yes",
        "error": 0,
        "type": "mobile",
        "status_message": "Success"
    },
    {
        "id": "3",
        "phone": 120111111111,
        "mcc": "310",
        "mnc": "260",
        "network": "T-Mobile US-SVR-10X/2",
        "ported": true,
        "status": 0,
        "present": "yes",
        "error": 0,
        "type": "mobile",
        "status_message": "Success"
    }
]
```

## Values

**ID**: a unique random ID which is created on the DecisionTelecom

**Phone**: int The telephone number.

**MCC**: the Mobile Country Code of the current carrier.

**MNC**: the Mobile Network Code of the current carrier.

**Network**: the name of the current carrier.

**Ported**: boolean, true / false / null.

**Type**: text label: mobile / fixed.

**Present**: yes/ no / na (not available) – whether the subscriber is present in the network.

**Status\_message**: text, the description of the above ‘status’: Success / Invalid Number / Not allowed country.

**Status**: number, a code for the outcome of the query:

0 = success

1 = invalid Number

2 = not allowed country

**HTTP Unsuccessful Response format**, If the status is not 0 (Success), only the number, status and status\_message will be returned.

**Example Response**: { "status\_message" : "Invalid Number", "status" : 1 }

**Errors**:

0-No error.

1-Unknown subscriber: The number is not allocated.

2-The owning network cannot be reached.

3-The network cannot reach the number.

4-The location of the number is not known to the network.

5-The number, as published in HLR, in not known to the MSC.

6-The number is absent for SM.

7-Unknown equipment.

8-Roaming not allowed.

9-Illegal subscriber.

10-Bearer service not provisioned.

11-Tele-service not provisioned.

12-Illegal equipment.

13-Call barred.

21-Facility not supported.

27-Phone switched off.

28-Incompatible terminal.

31-The subscriber is busy.

32-The delivery of the SM has failed.

33-A congestion (a full waiting list) occurred.

34-System failure.

35-Missing data.

36-Data error.

191-Unsupported network for which offers portability status.&#x20;

192-Unsupported network for which offers the Origin Network.&#x20;

193-Landline Fixed network (not covered).

## HLR examples

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

```
curl --location --request POST 'https://web.it-decision.com/v1/api/hlr' \
--header 'Authorization: Basic api key' \
--header 'Content-Type: application/json' \
--data-raw '{"phones":[380636151111,380631111112]}'

```

{% endtab %}

{% tab title="PHP" %}
\<?php

&#x20;

$curl = curl\_init();

&#x20;

curl\_setopt\_array($curl, array(

&#x20; CURLOPT\_URL => '<https://web.it-decision.com/v1/api/hlr>',

&#x20; CURLOPT\_RETURNTRANSFER => true,

&#x20; CURLOPT\_ENCODING => '',

&#x20; CURLOPT\_MAXREDIRS => 10,

&#x20; CURLOPT\_TIMEOUT => 0,

&#x20; CURLOPT\_FOLLOWLOCATION => true,

&#x20; CURLOPT\_HTTP\_VERSION => CURL\_HTTP\_VERSION\_1\_1,

&#x20; CURLOPT\_CUSTOMREQUEST => 'POST',

&#x20; CURLOPT\_POSTFIELDS =>'{"phones":\[380636151111,380631111112]}',

&#x20; CURLOPT\_HTTPHEADER => array(

&#x20;   'Authorization: Basic api key',

&#x20;   'Content-Type: application/json'

&#x20; ),

));

&#x20;

$response = curl\_exec($curl);

&#x20;

curl\_close($curl);

echo $response;
{% endtab %}

{% tab title="GOLANG" %}

```
package main

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

func main() {

  url := "https://web.it-decision.com/v1/api/hlr"
  method := "POST"

  payload := strings.NewReader(`{"phones":[380636151111,380631111112]}`)

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

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Basic api key ")
  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" %}

```
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"phones\":[380636151111,380631111112]}");
Request request = new Request.Builder()
  .url("https://web.it-decision.com/v1/api/hlr")
  .method("POST", body)
  .addHeader("Authorization", "Basic api key")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="C#" %}

```
var client = new RestClient("https://web.it-decision.com/v1/api/hlr");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic api key");
request.AddHeader("Content-Type", "application/json");
var body = @"{""phones"":[380636151111,380631111112]}";
request.AddParameter("application/json", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="C - libcurl" %}

```
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_easy_setopt(curl, CURLOPT_URL, "https://web.it-decision.com/v1/api/hlr");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Authorization: Basic api key");
  headers = curl_slist_append(headers, "Content-Type: application/json");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  const char *data = "{\"phones\":[380636151111,380631111112]}";
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
```

{% endtab %}

{% tab title="NodeJS" %}

```
ar https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'web.it-decision.com',
  'path': '/v1/api/hlr',
  'headers': {
    'Authorization': 'Basic api key',
    'Content-Type': 'application/json'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({
  "phones": [
    380636151111,
    380631111112
  ]
});

req.write(postData);

req.end();

```

{% endtab %}

{% tab title="Python" %}

```
import http.client
import json

conn = http.client.HTTPSConnection("web.it-decision.com")
payload = json.dumps({
  "phones": [
    380636151111,
    380631111112
  ]
})
headers = {
  'Authorization': 'Basic api key',
  'Content-Type': 'application/json'
}
conn.request("POST", "/v1/api/hlr", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

```

{% endtab %}

{% tab title="Ruby" %}

```
require "uri"
require "json"
require "net/http"

url = URI("https://web.it-decision.com/v1/api/hlr")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Basic api key"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
  "phones": [
    380636151111,
    380631111112
  ]
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}
