# HLR API

DecisionTelecom позволяет отправлять сетевые запросы на любой мобильный номер по всему миру. Это позволяет вам просматривать, какой номер мобильного телефона принадлежит какому оператору в режиме реального времени и видеть, активен ли номер.

HLR API использует HTTPS с ключом доступа, который используется в качестве авторизации API. Полезные данные запросов и ответов форматируются как JSON с использованием кодировки UTF-8 и значений в кодировке URL.

**API Авторизация** - Базовый ключ доступа Base64.

Чтобы получить ключ API, пожалуйста, свяжитесь с вашим менеджером по работе с клиентами.

## Отправить HLR

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

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

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Request JSON:" %}

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

{% endtab %}
{% endtabs %}

#### Параметры:&#x20;

**Phones**: <mark style="color:red;">array</mark> - Список номеров телефонов, по которым вы хотите выполнить сетевой запрос. – Обязательный.

#### **Response:**

Возвращает JSON string если запрос был успешным.

```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"
 }
]  
```

#### **Параметры:**

**Id** <mark style="color:orange;">int</mark> - Уникальный случайный идентификатор, созданный на платформе DecisionTelecom. Обязательный.

**status** <mark style="color:red;">string</mark> – состояние телефона.

**Возможные значения:** accepted, sent, absent, active, unknown, and failed.

## **Статус HLR**

#### **Пример запроса:**

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

```
https://web.it-decision.com/v1/api/hlr-status?id=2345234  
```

{% endtab %}
{% endtabs %}

#### **Пример ответа JSON:**

```json
{
    "id": 2345234,
    "phone": 38063122121,
    "mcc": "255",
    "mnc": "06",
    "network": "Lifecell",
    "ported": false,
    "status": 0,
    "error": 0,
    "type": "mobile",
    "present": "yes",
    "status_message": "Success"
}
```

## Значения

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

{% 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ru-api.decisiontele.com/hlr-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
